2019-08-16 00:50:54 +08:00
|
|
|
|
// Copyright (c) 2016-2019 Kiwano - Nomango
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-08-16 00:50:54 +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-08-16 00:50:54 +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-08-16 00:50:54 +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-12-27 10:51:34 +08:00
|
|
|
|
#include <kiwano/core/ObjectBase.h>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
#include <kiwano/core/Time.h>
|
2020-01-17 16:55:47 +08:00
|
|
|
|
#include <kiwano/render/Brush.h>
|
2020-02-05 19:56:22 +08:00
|
|
|
|
#include <kiwano/render/Shape.h>
|
2020-01-17 16:55:47 +08:00
|
|
|
|
#include <kiwano/render/LayerArea.h>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
#include <kiwano/render/TextLayout.h>
|
|
|
|
|
|
#include <kiwano/render/Texture.h>
|
2020-01-21 11:05:28 +08:00
|
|
|
|
#include <kiwano/render/DirectX/TextRenderer.h>
|
2019-08-16 00:50:54 +08:00
|
|
|
|
|
|
|
|
|
|
namespace kiwano
|
|
|
|
|
|
{
|
2020-01-21 10:09:55 +08:00
|
|
|
|
class Renderer;
|
|
|
|
|
|
|
|
|
|
|
|
KGE_DECLARE_SMART_PTR(RenderContext);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \addtogroup Render
|
|
|
|
|
|
* @{
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
enum class TextAntialiasMode
|
|
|
|
|
|
{
|
|
|
|
|
|
Default, ///< ϵͳĬ<CDB3><C4AC>
|
|
|
|
|
|
ClearType, ///< ClearType <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
GrayScale, ///< <20>Ҷȿ<D2B6><C8BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
None ///< <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @details
|
|
|
|
|
|
/// <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>ͼԪ<CDBC>Ļ<EFBFBD><C4BB>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>У<EFBFBD><D0A3>細<EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
class KGE_API RenderContext : public virtual ObjectBase
|
|
|
|
|
|
{
|
|
|
|
|
|
friend class Renderer;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD>Ч
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><>ʼ<EFBFBD><CABC>Ⱦ
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void BeginDraw();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱦ
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void EndDraw();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param texture <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param src_rect Դ<><D4B4><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param dest_rect <20><><EFBFBD>Ƶ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawTexture(Texture const& texture, Rect const& src_rect, Rect const& dest_rect);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param texture <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param src_rect Դ<><D4B4><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param dest_rect <20><><EFBFBD>Ƶ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawTexture(Texture const& texture, const Rect* src_rect = nullptr, const Rect* dest_rect = nullptr);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param layout <20>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param offset ƫ<><C6AB><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawTextLayout(TextLayout const& layout, Point const& offset = Point());
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param shape <20><>״
|
|
|
|
|
|
/// @param stroke <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
/// @param stroke_width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawShape(Shape const& shape, StrokeStylePtr stroke = nullptr, float stroke_width = 1.0f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>
|
|
|
|
|
|
/// @param point1 <20>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param point2 <20>߶<EFBFBD><DFB6>յ<EFBFBD>
|
|
|
|
|
|
/// @param stroke <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
/// @param stroke_width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawLine(Point const& point1, Point const& point2, StrokeStylePtr stroke = nullptr, float stroke_width = 1.0f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>ƾ<EFBFBD><C6BE>α߿<CEB1>
|
|
|
|
|
|
/// @param rect <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param stroke <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
/// @param stroke_width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawRectangle(Rect const& rect, StrokeStylePtr stroke = nullptr, float stroke_width = 1.0f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><C7BE>α߿<CEB1>
|
|
|
|
|
|
/// @param rect <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param radius Բ<>ǰ뾶
|
|
|
|
|
|
/// @param stroke <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
/// @param stroke_width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawRoundedRectangle(Rect const& rect, Vec2 const& radius, StrokeStylePtr stroke = nullptr,
|
|
|
|
|
|
float stroke_width = 1.0f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>߿<EFBFBD>
|
|
|
|
|
|
/// @param center Բ<><D4B2>
|
|
|
|
|
|
/// @param radius <20><>Բ<EFBFBD>뾶
|
|
|
|
|
|
/// @param stroke <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
/// @param stroke_width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void DrawEllipse(Point const& center, Vec2 const& radius, StrokeStylePtr stroke = nullptr,
|
|
|
|
|
|
float stroke_width = 1.0f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״
|
|
|
|
|
|
/// @param shape <20><>״
|
|
|
|
|
|
void FillShape(Shape const& shape);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param rect <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
void FillRectangle(Rect const& rect);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>
|
|
|
|
|
|
/// @param rect <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param radius Բ<>ǰ뾶
|
|
|
|
|
|
void FillRoundedRectangle(Rect const& rect, Vec2 const& radius);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ
|
|
|
|
|
|
/// @param center Բ<><D4B2>
|
|
|
|
|
|
/// @param radius <20><>Բ<EFBFBD>뾶
|
|
|
|
|
|
void FillEllipse(Point const& center, Vec2 const& radius);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param texture <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>С
|
2020-02-07 20:50:27 +08:00
|
|
|
|
void CreateTexture(Texture& texture, math::Vec2T<uint32_t> size);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>û<EFBFBD><C3BB>ƵIJü<C4B2><C3BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param clip_rect <20>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void PushClipRect(Rect const& clip_rect);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief ȡ<><C8A1><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>õĻ<C3B5><C4BB>Ʋü<C6B2><C3BC><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void PopClipRect();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param layer ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void PushLayer(LayerArea& layer);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief ȡ<><C8A1><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void PopLayer();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief ʹ<>ô<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param clear_color <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void Clear(Color const& clear_color);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
|
Size GetSize() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>ˢ<CBA2><CDB8><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
float GetBrushOpacity() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ˢ
|
2020-01-21 10:09:55 +08:00
|
|
|
|
BrushPtr GetCurrentBrush() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><>ȡȫ<C8A1>ֶ<EFBFBD>ά<EFBFBD>任
|
2020-01-21 10:09:55 +08:00
|
|
|
|
Matrix3x2 GetGlobalTransform() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>û<EFBFBD>ˢ<CBA2><CDB8><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetBrushOpacity(float opacity);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>ˢ
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetCurrentBrush(BrushPtr brush);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵĶ<C4B5>ά<EFBFBD>任
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetTransform(const Matrix3x2& matrix);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>ȫ<EFBFBD>ֶ<EFBFBD>ά<EFBFBD>任
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetGlobalTransform(const Matrix3x2& matrix);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>ȫ<EFBFBD>ֶ<EFBFBD>ά<EFBFBD>任
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetGlobalTransform(const Matrix3x2* matrix);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
void SetAntialiasMode(bool enabled);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
void SetTextAntialiasMode(TextAntialiasMode mode);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
bool CheckVisibility(Rect const& bounds, Matrix3x2 const& transform);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С
|
|
|
|
|
|
void Resize(Size const& size);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
struct Status
|
|
|
|
|
|
{
|
|
|
|
|
|
uint32_t primitives; ///< <20><>ȾͼԪ<CDBC><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
Time start; ///< <20><>Ⱦ<EFBFBD><C8BE>ʼʱ<CABC><CAB1>
|
|
|
|
|
|
Duration duration; ///< <20><>Ⱦʱ<C8BE><CAB1>
|
|
|
|
|
|
|
|
|
|
|
|
Status();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void SetCollectingStatus(bool enable);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
Status const& GetStatus() const;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
RenderContext();
|
|
|
|
|
|
|
|
|
|
|
|
ComPtr<ID2D1RenderTarget> GetRenderTarget() const;
|
|
|
|
|
|
|
|
|
|
|
|
ComPtr<ITextRenderer> GetTextRenderer() const;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|
|
|
|
|
HRESULT CreateDeviceResources(ComPtr<ID2D1Factory> factory, ComPtr<ID2D1RenderTarget> ctx);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|
|
|
|
|
void DiscardDeviceResources();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȾͼԪ<CDBC><D4AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
void IncreasePrimitivesCount(uint32_t increase = 1) const;
|
|
|
|
|
|
|
2020-02-03 14:15:30 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
void SaveDrawingState();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
void RestoreDrawingState();
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
private:
|
2020-02-03 14:15:30 +08:00
|
|
|
|
bool antialias_;
|
|
|
|
|
|
bool fast_global_transform_;
|
|
|
|
|
|
mutable bool collecting_status_;
|
|
|
|
|
|
float brush_opacity_;
|
|
|
|
|
|
TextAntialiasMode text_antialias_;
|
|
|
|
|
|
BrushPtr current_brush_;
|
|
|
|
|
|
Rect visible_size_;
|
|
|
|
|
|
Matrix3x2 global_transform_;
|
|
|
|
|
|
mutable Status status_;
|
|
|
|
|
|
|
|
|
|
|
|
ComPtr<ITextRenderer> text_renderer_;
|
|
|
|
|
|
ComPtr<ID2D1RenderTarget> render_target_;
|
|
|
|
|
|
ComPtr<ID2D1DrawingStateBlock> drawing_state_;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
inline RenderContext::Status::Status()
|
|
|
|
|
|
: primitives(0)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline RenderContext::Status const& RenderContext::GetStatus() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return status_;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ComPtr<ID2D1RenderTarget> RenderContext::GetRenderTarget() const
|
|
|
|
|
|
{
|
2020-02-03 14:15:30 +08:00
|
|
|
|
KGE_ASSERT(render_target_);
|
|
|
|
|
|
return render_target_;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ComPtr<ITextRenderer> RenderContext::GetTextRenderer() const
|
|
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(text_renderer_);
|
|
|
|
|
|
return text_renderer_;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline float RenderContext::GetBrushOpacity() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return brush_opacity_;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline BrushPtr RenderContext::GetCurrentBrush() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return current_brush_;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline Matrix3x2 RenderContext::GetGlobalTransform() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return global_transform_;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void RenderContext::SetBrushOpacity(float opacity)
|
|
|
|
|
|
{
|
|
|
|
|
|
brush_opacity_ = opacity;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void RenderContext::SetGlobalTransform(const Matrix3x2& matrix)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetGlobalTransform(&matrix);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void RenderContext::SetCurrentBrush(BrushPtr brush)
|
|
|
|
|
|
{
|
|
|
|
|
|
current_brush_ = brush;
|
|
|
|
|
|
if (current_brush_)
|
|
|
|
|
|
{
|
|
|
|
|
|
current_brush_->SetOpacity(brush_opacity_);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace kiwano
|