// 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 "helper.hpp" #include "../base/Resource.h" #include "../2d/Font.hpp" #include "../2d/TextStyle.hpp" #include #include #include namespace kiwano { MIDL_INTERFACE("5706684a-bf6d-4b03-b627-094758a33032") KGE_API ID2DDeviceResources : public IUnknown { public: static HRESULT Create(ID2DDeviceResources** device_resources); virtual HRESULT CreateBitmapFromFile( _Out_ ComPtr& bitmap, _In_ String const& file_path ) = 0; virtual HRESULT CreateBitmapFromResource( _Out_ ComPtr& bitmap, _In_ Resource const& res ) = 0; virtual HRESULT CreateTextFormat( _Out_ ComPtr& text_format, _In_ Font const& font, _In_ TextStyle const& text_style ) const = 0; virtual HRESULT CreateTextLayout( _Out_ ComPtr& text_layout, _Out_ Size& layout_size, _In_ String const& text, _In_ ComPtr const& text_format, _In_ TextStyle const& text_style ) const = 0; virtual ID2D1StrokeStyle* GetStrokeStyle(StrokeStyle stroke) const = 0; virtual HRESULT SetD2DDevice( _In_ ComPtr const& device ) = 0; virtual void SetTargetBitmap( _In_ ComPtr const& target ) = 0; virtual void ClearImageCache() = 0; virtual void DiscardResources() = 0; inline ID2D1Factory1* GetFactory() const { KGE_ASSERT(factory_); return factory_.Get(); } inline IWICImagingFactory* GetWICImagingFactory() const { KGE_ASSERT(imaging_factory_); return imaging_factory_.Get(); } inline IDWriteFactory* GetDWriteFactory() const { KGE_ASSERT(dwrite_factory_); return dwrite_factory_.Get(); } inline ID2D1Device* GetDevice() const { KGE_ASSERT(device_); return device_.Get(); } inline ID2D1DeviceContext* GetDeviceContext() const { KGE_ASSERT(device_context_); return device_context_.Get(); } inline ID2D1Bitmap1* GetTargetBitmap() const { KGE_ASSERT(target_bitmap_); return target_bitmap_.Get(); } protected: ComPtr factory_; ComPtr device_; ComPtr device_context_; ComPtr target_bitmap_; ComPtr imaging_factory_; ComPtr dwrite_factory_; }; }