diff --git a/appveyor.yml b/appveyor.yml index 27df39b0..9f7cf1bd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,8 @@ skip_tags: true # fetch repository as zip archive shallow_clone: true -# pull_requests: -# do_not_increment_build_number: true +pull_requests: + do_not_increment_build_number: true # Do not build feature branch with open Pull Requests # skip_branch_with_pr: true @@ -54,6 +54,9 @@ for: - master only_commits: message: /\[build\]/ + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + VS_PLATFORM_TOOLSET: v142 configuration: - Debug diff --git a/projects/kiwano.vcxproj b/projects/kiwano.vcxproj index c9958130..a1b790a9 100644 --- a/projects/kiwano.vcxproj +++ b/projects/kiwano.vcxproj @@ -28,7 +28,6 @@ - @@ -67,15 +66,18 @@ + + + @@ -98,7 +100,6 @@ - @@ -124,13 +125,16 @@ + + + diff --git a/projects/kiwano.vcxproj.filters b/projects/kiwano.vcxproj.filters index b3b2d69d..586733bf 100644 --- a/projects/kiwano.vcxproj.filters +++ b/projects/kiwano.vcxproj.filters @@ -48,9 +48,6 @@ 2d - - 2d - 2d @@ -294,6 +291,15 @@ renderer + + renderer + + + renderer + + + renderer + @@ -305,9 +311,6 @@ 2d - - 2d - 2d @@ -455,5 +458,14 @@ renderer + + renderer + + + renderer + + + renderer + \ No newline at end of file diff --git a/src/kiwano/2d/Transition.cpp b/src/kiwano/2d/Transition.cpp index d5353c05..8fe41b9c 100644 --- a/src/kiwano/2d/Transition.cpp +++ b/src/kiwano/2d/Transition.cpp @@ -39,10 +39,8 @@ namespace kiwano , window_size_() , out_scene_(nullptr) , in_scene_(nullptr) - , out_layer_(nullptr) - , in_layer_(nullptr) - , out_layer_prop_() - , in_layer_prop_() + , out_layer_() + , in_layer_() { } @@ -74,7 +72,8 @@ namespace kiwano } window_size_ = Renderer::GetInstance()->GetOutputSize(); - out_layer_prop_ = in_layer_prop_ = LayerProperties{ Rect(Point(), window_size_),1.f }; + out_layer_.SetAreaRect(Rect{ Point(), window_size_ }); + in_layer_.SetAreaRect(Rect{ Point(), window_size_ }); } void Transition::Update(Duration dt) @@ -101,7 +100,7 @@ namespace kiwano { renderer->SetTransform(out_scene_->GetTransformMatrix()); renderer->PushClipRect(Rect{ Point{}, window_size_ }); - renderer->PushLayer(out_layer_, out_layer_prop_); + renderer->PushLayer(out_layer_); out_scene_->Render(renderer); @@ -113,7 +112,7 @@ namespace kiwano { renderer->SetTransform(in_scene_->GetTransformMatrix()); renderer->PushClipRect(Rect{ Point{}, window_size_ }); - renderer->PushLayer(in_layer_, in_layer_prop_); + renderer->PushLayer(in_layer_); in_scene_->Render(renderer); @@ -141,7 +140,7 @@ namespace kiwano { Transition::Init(prev, next); - in_layer_prop_.opacity = 0; + in_layer_.SetOpacity(0.f); } void BoxTransition::Update(Duration dt) @@ -150,22 +149,26 @@ namespace kiwano if (process_ < .5f) { - out_layer_prop_.area = Rect( - window_size_.x * process_, - window_size_.y * process_, - window_size_.x * (1 - process_ * 2), - window_size_.y * (1 - process_ * 2) + out_layer_.SetAreaRect( + Rect( + window_size_.x * process_, + window_size_.y * process_, + window_size_.x * (1 - process_ * 2), + window_size_.y * (1 - process_ * 2) + ) ); } else { - out_layer_prop_.opacity = 0; - in_layer_prop_.opacity = 1; - in_layer_prop_.area = Rect( - window_size_.x * (1 - process_), - window_size_.y * (1 - process_), - window_size_.x * (2 * process_ - 1), - window_size_.y * (2 * process_ - 1) + out_layer_.SetOpacity(0.f); + in_layer_.SetOpacity(1.f); + in_layer_.SetAreaRect( + Rect( + window_size_.x * (1 - process_), + window_size_.y * (1 - process_), + window_size_.x * (2 * process_ - 1), + window_size_.y * (2 * process_ - 1) + ) ); } } @@ -183,16 +186,16 @@ namespace kiwano { Transition::Init(prev, next); - out_layer_prop_.opacity = 1; - in_layer_prop_.opacity = 0; + out_layer_.SetOpacity(1.f); + in_layer_.SetOpacity(0.f); } void EmergeTransition::Update(Duration dt) { Transition::Update(dt); - out_layer_prop_.opacity = 1 - process_; - in_layer_prop_.opacity = process_; + out_layer_.SetOpacity(1 - process_); + in_layer_.SetOpacity(process_); } //------------------------------------------------------- @@ -208,8 +211,8 @@ namespace kiwano { Transition::Init(prev, next); - out_layer_prop_.opacity = 1; - in_layer_prop_.opacity = 0; + out_layer_.SetOpacity(1.f); + in_layer_.SetOpacity(0.f); } void FadeTransition::Update(Duration dt) @@ -218,13 +221,13 @@ namespace kiwano if (process_ < 0.5) { - out_layer_prop_.opacity = 1 - process_ * 2; - in_layer_prop_.opacity = 0; + out_layer_.SetOpacity(1 - process_ * 2); + in_layer_.SetOpacity(0.f); } else { - out_layer_prop_.opacity = 0; - in_layer_prop_.opacity = (process_ - 0.5f) * 2; + out_layer_.SetOpacity(0.f); + in_layer_.SetOpacity((process_ - 0.5f) * 2); } } @@ -336,7 +339,7 @@ namespace kiwano in_scene_->SetAnchor(0.5f, 0.5f); } - in_layer_prop_.opacity = 0; + in_layer_.SetOpacity(0.f); } void RotationTransition::Update(Duration dt) @@ -357,8 +360,8 @@ namespace kiwano { if (in_scene_) { - out_layer_prop_.opacity = 0; - in_layer_prop_.opacity = 1; + out_layer_.SetOpacity(0.f); + in_layer_.SetOpacity(1.f); auto transform = in_scene_->GetTransform(); transform.scale = Point{ (process_ - .5f) * 2, (process_ - .5f) * 2 }; diff --git a/src/kiwano/2d/Transition.h b/src/kiwano/2d/Transition.h index 63cd9642..67dc8900 100644 --- a/src/kiwano/2d/Transition.h +++ b/src/kiwano/2d/Transition.h @@ -20,7 +20,7 @@ #pragma once #include "include-forwards.h" -#include +#include "../renderer/LayerArea.h" namespace kiwano { @@ -57,17 +57,15 @@ namespace kiwano virtual void Reset() { }; protected: - bool done_; - float process_; - Duration duration_; - Duration delta_; - Size window_size_; - StagePtr out_scene_; - StagePtr in_scene_; - ComPtr out_layer_; - ComPtr in_layer_; - LayerProperties out_layer_prop_; - LayerProperties in_layer_prop_; + bool done_; + float process_; + Duration duration_; + Duration delta_; + Size window_size_; + StagePtr out_scene_; + StagePtr in_scene_; + LayerArea out_layer_; + LayerArea in_layer_; }; diff --git a/src/kiwano/2d/include-forwards.h b/src/kiwano/2d/include-forwards.h index 98f832e4..97473233 100644 --- a/src/kiwano/2d/include-forwards.h +++ b/src/kiwano/2d/include-forwards.h @@ -19,15 +19,15 @@ // THE SOFTWARE. #pragma once -#include "Color.h" #include "../core/core.h" #include "../base/time.h" #include "../base/RefCounter.hpp" #include "../base/SmartPtr.hpp" #include "../base/ComPtr.hpp" #include "../base/Object.h" -#include "../math/helper.h" #include "../base/types.h" +#include "../math/helper.h" +#include "../renderer/Color.h" namespace kiwano { diff --git a/src/kiwano/base/types.h b/src/kiwano/base/types.h index 54531e14..b3045ffb 100644 --- a/src/kiwano/base/types.h +++ b/src/kiwano/base/types.h @@ -61,11 +61,4 @@ namespace kiwano GrayScale, // »Ò¶È¿¹¾â³Ý None // ²»ÆôÓÿ¹¾â³Ý }; - - // ͼ²ãÊôÐÔ - struct LayerProperties - { - Rect area; - float opacity; - }; } diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h index 32e44077..34ab234e 100644 --- a/src/kiwano/kiwano.h +++ b/src/kiwano/kiwano.h @@ -59,11 +59,14 @@ // renderer // +#include "renderer/Color.h" +#include "renderer/Font.h" #include "renderer/Image.h" #include "renderer/GifImage.h" #include "renderer/TextLayout.h" #include "renderer/TextRenderer.h" #include "renderer/Geometry.h" +#include "renderer/LayerArea.h" #include "renderer/ImageCache.h" #include "renderer/RenderTarget.h" #include "renderer/Renderer.h" @@ -96,8 +99,7 @@ // 2d // -#include "2d/Font.hpp" -#include "2d/Color.h" + #include "2d/Transform.hpp" #include "2d/TextStyle.hpp" diff --git a/src/kiwano/platform/Application.h b/src/kiwano/platform/Application.h index 595bbbb3..bb8804ee 100644 --- a/src/kiwano/platform/Application.h +++ b/src/kiwano/platform/Application.h @@ -23,7 +23,7 @@ #include "../base/time.h" #include "../base/Component.h" #include "../base/Event.hpp" -#include "../2d/Color.h" +#include "../renderer/Color.h" namespace kiwano { diff --git a/src/kiwano/2d/Color.cpp b/src/kiwano/renderer/Color.cpp similarity index 100% rename from src/kiwano/2d/Color.cpp rename to src/kiwano/renderer/Color.cpp diff --git a/src/kiwano/2d/Color.h b/src/kiwano/renderer/Color.h similarity index 100% rename from src/kiwano/2d/Color.h rename to src/kiwano/renderer/Color.h diff --git a/src/kiwano/renderer/D2DDeviceResources.h b/src/kiwano/renderer/D2DDeviceResources.h index a425f806..cd304459 100644 --- a/src/kiwano/renderer/D2DDeviceResources.h +++ b/src/kiwano/renderer/D2DDeviceResources.h @@ -20,8 +20,8 @@ #pragma once #include "helper.hpp" +#include "Font.h" #include "../base/Resource.h" -#include "../2d/Font.hpp" #include "../2d/TextStyle.hpp" #include #include diff --git a/src/kiwano/renderer/D3DDeviceResourcesBase.h b/src/kiwano/renderer/D3DDeviceResourcesBase.h index d742c41f..e378649c 100644 --- a/src/kiwano/renderer/D3DDeviceResourcesBase.h +++ b/src/kiwano/renderer/D3DDeviceResourcesBase.h @@ -21,7 +21,7 @@ #pragma once #include "../macros.h" #include "../math/helper.h" -#include "../2d/Color.h" +#include "Color.h" #include namespace kiwano diff --git a/src/kiwano/renderer/Font.cpp b/src/kiwano/renderer/Font.cpp new file mode 100644 index 00000000..20ce297b --- /dev/null +++ b/src/kiwano/renderer/Font.cpp @@ -0,0 +1,32 @@ +// 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. + +#include "Font.h" + +namespace kiwano +{ + Font::Font(const String& family, float size, unsigned int weight, bool italic) + : family(family) + , size(size) + , weight(weight) + , italic(italic) + { + } +} diff --git a/src/kiwano/2d/Font.hpp b/src/kiwano/renderer/Font.h similarity index 85% rename from src/kiwano/2d/Font.hpp rename to src/kiwano/renderer/Font.h index 091679a3..fc402f2b 100644 --- a/src/kiwano/2d/Font.hpp +++ b/src/kiwano/renderer/Font.h @@ -19,22 +19,22 @@ // THE SOFTWARE. #pragma once -#include +#include "../core/core.h" namespace kiwano { // ×ÖÌå´Öϸֵ enum FontWeight : unsigned int { - Thin = 100, - ExtraLight = 200, - Light = 300, - Normal = 400, - Medium = 500, - Bold = 700, - ExtraBold = 800, - Black = 900, - ExtraBlack = 950 + Thin = 100, + ExtraLight = 200, + Light = 300, + Normal = 400, + Medium = 500, + Bold = 700, + ExtraBold = 800, + Black = 900, + ExtraBlack = 950 }; // ×ÖÌå @@ -52,12 +52,6 @@ namespace kiwano float size = 18, unsigned int weight = FontWeight::Normal, bool italic = false - ) - : family(family) - , size(size) - , weight(weight) - , italic(italic) - { - } + ); }; } diff --git a/src/kiwano/renderer/LayerArea.cpp b/src/kiwano/renderer/LayerArea.cpp new file mode 100644 index 00000000..a81ddddd --- /dev/null +++ b/src/kiwano/renderer/LayerArea.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2016-2019 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. + +#include "LayerArea.h" + +namespace kiwano +{ + LayerArea::LayerArea() + : opacity_(1.f) + { + } + + bool LayerArea::IsValid() const + { + return layer_ != nullptr; + } + + Size LayerArea::GetSize() const + { + if (layer_) + { + return reinterpret_cast(layer_->GetSize()); + } + return Size(); + } + +} diff --git a/src/kiwano/renderer/LayerArea.h b/src/kiwano/renderer/LayerArea.h new file mode 100644 index 00000000..92e2848e --- /dev/null +++ b/src/kiwano/renderer/LayerArea.h @@ -0,0 +1,60 @@ +// Copyright (c) 2016-2019 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 "D2DDeviceResources.h" +#include "Geometry.h" + +namespace kiwano +{ + // ͼ²ã + class KGE_API LayerArea + { + public: + LayerArea(); + + bool IsValid() const; + + Size GetSize() const; + + inline Rect const& GetAreaRect() const { return area_; } + + inline void SetAreaRect(Rect const& area) { area_ = area; } + + inline float GetOpacity() const { return opacity_; } + + inline void SetOpacity(float opacity) { opacity_ = opacity; } + + inline Geometry const& GetMaskGeometry() const { return mask_; } + + inline void SetMaskGeometry(Geometry const& mask) { mask_ = mask; } + + public: + inline ComPtr GetLayer() const { return layer_; } + + inline void SetLayer(ComPtr layer) { layer_ = layer; } + + protected: + Rect area_; + float opacity_; + Geometry mask_; + ComPtr layer_; + }; +} diff --git a/src/kiwano/renderer/RenderTarget.cpp b/src/kiwano/renderer/RenderTarget.cpp index 5dcb8b35..1403d109 100644 --- a/src/kiwano/renderer/RenderTarget.cpp +++ b/src/kiwano/renderer/RenderTarget.cpp @@ -389,10 +389,9 @@ namespace kiwano ThrowIfFailed(hr); } - void RenderTarget::CreateLayer(ComPtr& layer) const + void RenderTarget::CreateLayer(LayerArea& layer) const { HRESULT hr = S_OK; - ComPtr new_layer; if (!render_target_) { @@ -401,12 +400,13 @@ namespace kiwano if (SUCCEEDED(hr)) { - hr = render_target_->CreateLayer(&new_layer); - } + ComPtr output; + hr = render_target_->CreateLayer(&output); - if (SUCCEEDED(hr)) - { - layer = new_layer; + if (SUCCEEDED(hr)) + { + layer.SetLayer(output); + } } ThrowIfFailed(hr); @@ -424,7 +424,7 @@ namespace kiwano { render_target_->PushAxisAlignedClip( DX::ConvertToRectF(clip_rect), - D2D1_ANTIALIAS_MODE_PER_PRIMITIVE + antialias_ ? D2D1_ANTIALIAS_MODE_PER_PRIMITIVE : D2D1_ANTIALIAS_MODE_ALIASED ); } @@ -447,7 +447,7 @@ namespace kiwano ThrowIfFailed(hr); } - void RenderTarget::PushLayer(ComPtr const& layer, LayerProperties const& properties) + void RenderTarget::PushLayer(LayerArea const& layer) { HRESULT hr = S_OK; if (!render_target_ || !solid_color_brush_) @@ -455,19 +455,19 @@ namespace kiwano hr = E_UNEXPECTED; } - if (SUCCEEDED(hr)) + if (SUCCEEDED(hr) && layer.IsValid()) { render_target_->PushLayer( D2D1::LayerParameters( - DX::ConvertToRectF(properties.area), - nullptr, - D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, + DX::ConvertToRectF(layer.GetAreaRect()), + layer.GetMaskGeometry().GetGeometry().get(), + antialias_ ? D2D1_ANTIALIAS_MODE_PER_PRIMITIVE : D2D1_ANTIALIAS_MODE_ALIASED, D2D1::Matrix3x2F::Identity(), - properties.opacity, + layer.GetOpacity(), nullptr, D2D1_LAYER_OPTIONS_NONE ), - layer.get() + layer.GetLayer().get() ); } diff --git a/src/kiwano/renderer/RenderTarget.h b/src/kiwano/renderer/RenderTarget.h index 5619bd30..74ec7b51 100644 --- a/src/kiwano/renderer/RenderTarget.h +++ b/src/kiwano/renderer/RenderTarget.h @@ -24,6 +24,7 @@ #include "Geometry.h" #include "TextLayout.h" #include "TextRenderer.h" +#include "LayerArea.h" namespace kiwano { @@ -37,7 +38,7 @@ namespace kiwano void EndDraw(); void CreateLayer( - ComPtr& layer + LayerArea& layer ) const; void DrawGeometry( @@ -124,8 +125,7 @@ namespace kiwano void PopClipRect(); void PushLayer( - ComPtr const& layer, - LayerProperties const& properties + LayerArea const& layer ); void PopLayer(); diff --git a/src/kiwano/renderer/TextLayout.h b/src/kiwano/renderer/TextLayout.h index a9aebe9c..3fc3add2 100644 --- a/src/kiwano/renderer/TextLayout.h +++ b/src/kiwano/renderer/TextLayout.h @@ -20,7 +20,7 @@ #pragma once #include "D2DDeviceResources.h" -#include "../2d/Font.hpp" +#include "Font.h" #include "../2d/TextStyle.hpp" namespace kiwano diff --git a/src/kiwano/renderer/helper.hpp b/src/kiwano/renderer/helper.hpp index 3c781b1b..ace4bd9f 100644 --- a/src/kiwano/renderer/helper.hpp +++ b/src/kiwano/renderer/helper.hpp @@ -21,7 +21,7 @@ #pragma once #include "../base/ComPtr.hpp" #include "../math/helper.h" -#include "../2d/Color.h" +#include "Color.h" #include namespace kiwano