Magic_Game/src/kiwano/render/DirectX/RendererImpl.h

105 lines
3.6 KiB
C
Raw Normal View History

// Copyright (c) 2016-2018 Kiwano - Nomango
//
// 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:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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
#include <kiwano/render/Renderer.h>
2020-05-22 21:07:32 +08:00
#include <kiwano/render/DirectX/D3DDeviceResources.h>
#include <kiwano/render/DirectX/RenderContextImpl.h>
namespace kiwano
{
class KGE_API RendererImpl
: public Renderer
{
public:
static RendererImpl& GetInstance();
2020-02-19 12:09:50 +08:00
void CreateTexture(Texture& texture, const String& file_path) override;
void CreateTexture(Texture& texture, const BinaryData& data) override;
void CreateTexture(Texture& texture, const PixelSize& size, const BinaryData& data, PixelFormat format);
2020-02-19 12:09:50 +08:00
void CreateGifImage(GifImage& gif, const String& file_path) override;
void CreateGifImage(GifImage& gif, const BinaryData& data) override;
2020-02-19 12:09:50 +08:00
void CreateGifImageFrame(GifImage::Frame& frame, const GifImage& gif, size_t frame_index) override;
2020-08-04 02:19:23 +08:00
void CreateFontCollection(Font& font, Vector<String>& family_names, const String& file_path) override;
void CreateFontCollection(Font& font, Vector<String>& family_names, const BinaryData& data) override;
2020-02-16 12:53:18 +08:00
void CreateTextLayout(TextLayout& layout, const String& content, const TextStyle& style) override;
2020-02-19 12:09:50 +08:00
void CreateLineShape(Shape& shape, const Point& begin_pos, const Point& end_pos) override;
2020-02-19 12:09:50 +08:00
void CreateRectShape(Shape& shape, const Rect& rect) override;
2020-02-19 12:09:50 +08:00
void CreateRoundedRectShape(Shape& shape, const Rect& rect, const Vec2& radius) override;
2020-02-19 12:09:50 +08:00
void CreateEllipseShape(Shape& shape, const Point& center, const Vec2& radius) override;
2020-02-16 20:14:01 +08:00
void CreateShapeSink(ShapeMaker& maker) override;
2020-02-19 12:09:50 +08:00
void CreateBrush(Brush& brush, const Color& color) override;
2020-02-19 12:09:50 +08:00
void CreateBrush(Brush& brush, const LinearGradientStyle& style) override;
2020-02-19 12:09:50 +08:00
void CreateBrush(Brush& brush, const RadialGradientStyle& style) override;
2020-02-16 20:32:08 +08:00
void CreateBrush(Brush& brush, TexturePtr texture) override;
2020-02-16 20:14:01 +08:00
void CreateStrokeStyle(StrokeStyle& stroke_style) override;
RenderContextPtr CreateTextureRenderContext(Texture& texture, const Size* desired_size = nullptr) override;
public:
2020-02-14 22:01:56 +08:00
void Clear() override;
2020-02-14 22:01:56 +08:00
void Present() override;
2020-02-14 22:01:56 +08:00
void Resize(uint32_t width, uint32_t height) override;
2020-02-14 22:01:56 +08:00
void MakeContextForWindow(WindowPtr window) override;
2020-02-14 22:01:56 +08:00
void Destroy() override;
2020-08-04 02:19:23 +08:00
void HandleEvent(EventModuleContext& ctx) override;
2020-05-29 18:44:20 +08:00
protected:
RendererImpl();
private:
2020-05-22 21:07:32 +08:00
using ID2DDeviceResources = kiwano::graphics::directx::ID2DDeviceResources;
using ID3DDeviceResources = kiwano::graphics::directx::ID3DDeviceResources;
ComPtr<ID2DDeviceResources> d2d_res_;
ComPtr<ID3DDeviceResources> d3d_res_;
2020-08-04 02:19:23 +08:00
HMONITOR monitor_;
};
2020-05-22 21:07:32 +08:00
/** @} */
} // namespace kiwano