update intrusive_ptr
This commit is contained in:
parent
7b39d4bd98
commit
03edd40ecd
|
|
@ -118,7 +118,7 @@ namespace kiwano
|
||||||
void SoundPlayer::SetVolume(float volume)
|
void SoundPlayer::SetVolume(float volume)
|
||||||
{
|
{
|
||||||
volume_ = std::min(std::max(volume, -224.f), 224.f);
|
volume_ = std::min(std::max(volume, -224.f), 224.f);
|
||||||
for (const auto& pair : sound_cache_)
|
for (auto& pair : sound_cache_)
|
||||||
{
|
{
|
||||||
pair.second->SetVolume(volume_);
|
pair.second->SetVolume(volume_);
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +126,7 @@ namespace kiwano
|
||||||
|
|
||||||
void SoundPlayer::PauseAll()
|
void SoundPlayer::PauseAll()
|
||||||
{
|
{
|
||||||
for (const auto& pair : sound_cache_)
|
for (auto& pair : sound_cache_)
|
||||||
{
|
{
|
||||||
pair.second->Pause();
|
pair.second->Pause();
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +134,7 @@ namespace kiwano
|
||||||
|
|
||||||
void SoundPlayer::ResumeAll()
|
void SoundPlayer::ResumeAll()
|
||||||
{
|
{
|
||||||
for (const auto& pair : sound_cache_)
|
for (auto& pair : sound_cache_)
|
||||||
{
|
{
|
||||||
pair.second->Resume();
|
pair.second->Resume();
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,7 @@ namespace kiwano
|
||||||
|
|
||||||
void SoundPlayer::StopAll()
|
void SoundPlayer::StopAll()
|
||||||
{
|
{
|
||||||
for (const auto& pair : sound_cache_)
|
for (auto& pair : sound_cache_)
|
||||||
{
|
{
|
||||||
pair.second->Stop();
|
pair.second->Stop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GearJoint::GearJoint(World* world, GearJoint::Param const& param)
|
GearJoint::GearJoint(World* world, GearJoint::Param param)
|
||||||
: Joint()
|
: Joint()
|
||||||
, raw_joint_(nullptr)
|
, raw_joint_(nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ namespace kiwano
|
||||||
|
|
||||||
GearJoint();
|
GearJoint();
|
||||||
GearJoint(World* world, b2GearJointDef* def);
|
GearJoint(World* world, b2GearJointDef* def);
|
||||||
GearJoint(World* world, Param const& param);
|
GearJoint(World* world, Param param);
|
||||||
|
|
||||||
// 设定齿轮传动比
|
// 设定齿轮传动比
|
||||||
void SetRatio(float ratio);
|
void SetRatio(float ratio);
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
|
|
||||||
// update children's transform
|
// update children's transform
|
||||||
for (Actor* child = children_.first_item().get(); child; child = child->next_item().get())
|
for (auto child = children_.first_item().get(); child; child = child->next_item().get())
|
||||||
child->dirty_transform_ = true;
|
child->dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -527,11 +527,11 @@ namespace kiwano
|
||||||
Vector<ActorPtr> children;
|
Vector<ActorPtr> children;
|
||||||
size_t hash_code = std::hash<String>{}(name);
|
size_t hash_code = std::hash<String>{}(name);
|
||||||
|
|
||||||
for (Actor* child = children_.first_item().get(); child; child = child->next_item().get())
|
for (auto child = children_.first_item().get(); child; child = child->next_item().get())
|
||||||
{
|
{
|
||||||
if (child->hash_name_ == hash_code && child->IsName(name))
|
if (child->hash_name_ == hash_code && child->IsName(name))
|
||||||
{
|
{
|
||||||
children.push_back(child);
|
children.push_back(const_cast<Actor*>(child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return children;
|
return children;
|
||||||
|
|
@ -541,11 +541,11 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
size_t hash_code = std::hash<String>{}(name);
|
size_t hash_code = std::hash<String>{}(name);
|
||||||
|
|
||||||
for (Actor* child = children_.first_item().get(); child; child = child->next_item().get())
|
for (auto child = children_.first_item().get(); child; child = child->next_item().get())
|
||||||
{
|
{
|
||||||
if (child->hash_name_ == hash_code && child->IsName(name))
|
if (child->hash_name_ == hash_code && child->IsName(name))
|
||||||
{
|
{
|
||||||
return child;
|
return const_cast<Actor*>(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -247,9 +247,9 @@ namespace kiwano
|
||||||
TextStyle text_style_;
|
TextStyle text_style_;
|
||||||
StrokeStyle stroke_style_;
|
StrokeStyle stroke_style_;
|
||||||
GeometrySink geo_sink_;
|
GeometrySink geo_sink_;
|
||||||
TextureRenderTarget rt_;
|
|
||||||
|
|
||||||
mutable bool cache_expired_;
|
mutable bool cache_expired_;
|
||||||
mutable Texture texture_cached_;
|
mutable Texture texture_cached_;
|
||||||
|
mutable TextureRenderTarget rt_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ class intrusive_list_item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using value_type = _Ty;
|
using value_type = _Ty;
|
||||||
using reference = value_type&;
|
using reference = _Ty&;
|
||||||
using const_reference = const value_type&;
|
using const_reference = const _Ty&;
|
||||||
|
|
||||||
intrusive_list_item() : prev_(), next_() {}
|
intrusive_list_item() : prev_(), next_() {}
|
||||||
intrusive_list_item(_Ty const& rhs) : prev_(rhs->prev_), next_(rhs->next_) {}
|
intrusive_list_item(_Ty const& rhs) : prev_(rhs->prev_), next_(rhs->next_) {}
|
||||||
|
|
@ -80,7 +80,7 @@ public:
|
||||||
reference last_item() { return last_; }
|
reference last_item() { return last_; }
|
||||||
bool empty() const { return !first_; }
|
bool empty() const { return !first_; }
|
||||||
|
|
||||||
void push_back(const_reference child)
|
void push_back(value_type child)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -104,7 +104,7 @@ public:
|
||||||
KGE_DEBUG_CHECK_LIST(this);
|
KGE_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_front(const_reference child)
|
void push_front(value_type child)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -128,7 +128,7 @@ public:
|
||||||
KGE_DEBUG_CHECK_LIST(this);
|
KGE_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_before(const_reference child, const_reference before)
|
void insert_before(value_type child, value_type before)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -147,7 +147,7 @@ public:
|
||||||
KGE_DEBUG_CHECK_LIST(this);
|
KGE_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_after(const_reference child, const_reference after)
|
void insert_after(value_type child, value_type after)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -166,7 +166,7 @@ public:
|
||||||
KGE_DEBUG_CHECK_LIST(this);
|
KGE_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const_reference child)
|
void remove(value_type child)
|
||||||
{
|
{
|
||||||
#ifdef KGE_DEBUG_ENABLE_LIST_CHECK
|
#ifdef KGE_DEBUG_ENABLE_LIST_CHECK
|
||||||
_Ty tmp = first_;
|
_Ty tmp = first_;
|
||||||
|
|
|
||||||
|
|
@ -36,35 +36,40 @@ public:
|
||||||
using value_type = _Ty;
|
using value_type = _Ty;
|
||||||
using pointer_type = _Ty*;
|
using pointer_type = _Ty*;
|
||||||
using const_pointer_type = const _Ty*;
|
using const_pointer_type = const _Ty*;
|
||||||
|
using reference_type = _Ty&;
|
||||||
|
using const_reference_type = const _Ty&;
|
||||||
using manager_type = _ManagerTy;
|
using manager_type = _ManagerTy;
|
||||||
|
|
||||||
intrusive_ptr() noexcept {}
|
intrusive_ptr() noexcept : ptr_(nullptr) {}
|
||||||
intrusive_ptr(std::nullptr_t) noexcept {}
|
intrusive_ptr(std::nullptr_t) noexcept : ptr_(nullptr) {}
|
||||||
intrusive_ptr(pointer_type p) : ptr_(p) { typename manager_type::AddRef(ptr_); }
|
intrusive_ptr(pointer_type p) : ptr_(p) { typename manager_type::AddRef(ptr_); }
|
||||||
intrusive_ptr(const intrusive_ptr& other) : ptr_(other.ptr_) { typename manager_type::AddRef(ptr_); }
|
intrusive_ptr(const intrusive_ptr& other) : ptr_(other.ptr_) { typename manager_type::AddRef(ptr_); }
|
||||||
intrusive_ptr(intrusive_ptr&& other) noexcept { ptr_ = other.ptr_; other.ptr_ = nullptr; }
|
intrusive_ptr(intrusive_ptr&& other) noexcept : ptr_(nullptr) { swap(other); }
|
||||||
~intrusive_ptr() { typename manager_type::Release(ptr_); }
|
~intrusive_ptr() { reset(); }
|
||||||
|
|
||||||
template <typename _UTy>
|
template <typename _UTy>
|
||||||
intrusive_ptr(const intrusive_ptr<_UTy, manager_type>& other) : ptr_(other.get()) { typename manager_type::AddRef(ptr_); }
|
intrusive_ptr(const intrusive_ptr<_UTy, manager_type>& other) { ptr_ = const_cast<pointer_type>(dynamic_cast<const_pointer_type>(other.get())); typename manager_type::AddRef(ptr_); }
|
||||||
|
|
||||||
inline pointer_type get() const noexcept { return ptr_; }
|
inline pointer_type get() noexcept { return ptr_; }
|
||||||
inline void reset(pointer_type ptr = nullptr) { intrusive_ptr{ ptr }.swap(*this); }
|
inline const_pointer_type get() const noexcept { return ptr_; }
|
||||||
inline void swap(intrusive_ptr& other) noexcept { std::swap(ptr_, other.ptr_); }
|
inline void reset(pointer_type ptr = nullptr) { typename manager_type::Release(ptr_); ptr_ = nullptr; }
|
||||||
|
inline void swap(intrusive_ptr& other) noexcept { std::swap(ptr_, other.ptr_); }
|
||||||
|
|
||||||
inline pointer_type operator ->() const { KGE_ASSERT(ptr_ != nullptr && "Invalid pointer"); return ptr_; }
|
inline pointer_type operator ->() { KGE_ASSERT(ptr_ != nullptr && "Invalid pointer"); return ptr_; }
|
||||||
inline value_type& operator *() const { KGE_ASSERT(ptr_ != nullptr && "Invalid pointer"); return *ptr_; }
|
inline const_pointer_type operator ->() const { KGE_ASSERT(ptr_ != nullptr && "Invalid pointer"); return ptr_; }
|
||||||
inline pointer_type* operator &() { KGE_ASSERT(ptr_ == nullptr && "Memory leak"); return &ptr_; }
|
inline reference_type operator *() { KGE_ASSERT(ptr_ != nullptr && "Invalid pointer"); return *ptr_; }
|
||||||
inline operator bool() const noexcept { return ptr_ != nullptr; }
|
inline const_reference_type operator *() const { KGE_ASSERT(ptr_ != nullptr && "Invalid pointer"); return *ptr_; }
|
||||||
inline bool operator !() const noexcept { return ptr_ == 0; }
|
inline pointer_type* operator &() { KGE_ASSERT(ptr_ == nullptr && "Memory leak"); return &ptr_; }
|
||||||
|
inline operator bool() const noexcept { return ptr_ != nullptr; }
|
||||||
|
inline bool operator !() const noexcept { return ptr_ == 0; }
|
||||||
|
|
||||||
inline const intrusive_ptr& operator=(const intrusive_ptr& other) const { if (other.ptr_ != ptr_) intrusive_ptr(other).swap(*const_cast<intrusive_ptr*>(this)); return *this; }
|
inline intrusive_ptr& operator=(const intrusive_ptr& other) { if (other.ptr_ != ptr_) intrusive_ptr(other).swap(*this); return (*this); }
|
||||||
inline const intrusive_ptr& operator=(intrusive_ptr&& other) const noexcept { if (other.ptr_ != ptr_) other.swap(*const_cast<intrusive_ptr*>(this)); return *this; }
|
inline intrusive_ptr& operator=(intrusive_ptr&& other) noexcept { if (other.ptr_ != ptr_) other.swap(*this); return (*this); }
|
||||||
inline const intrusive_ptr& operator=(pointer_type p) const { if (p != ptr_) intrusive_ptr(p).swap(*const_cast<intrusive_ptr*>(this)); return *this; }
|
inline intrusive_ptr& operator=(pointer_type p) { if (p != ptr_) intrusive_ptr(p).swap(*this); return (*this); }
|
||||||
inline const intrusive_ptr& operator=(std::nullptr_t) const noexcept { if (nullptr != ptr_) intrusive_ptr{}.swap(*const_cast<intrusive_ptr*>(this)); return *this; }
|
inline intrusive_ptr& operator=(std::nullptr_t) { reset(); return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pointer_type ptr_{ nullptr };
|
pointer_type ptr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class _Ty, class _UTy, class manager_type>
|
template <class _Ty, class _UTy, class manager_type>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <exception>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -92,14 +92,10 @@ namespace kiwano
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Geometry Geometry::CombineWith(Geometry input, CombineMode mode, Matrix3x2 const& input_matrix) const
|
void Geometry::CombineWith(GeometrySink& sink, Geometry input, CombineMode mode, Matrix3x2 const& input_matrix) const
|
||||||
{
|
{
|
||||||
if (geo_ && input.geo_)
|
if (geo_ && input.geo_)
|
||||||
{
|
{
|
||||||
GeometrySink sink;
|
|
||||||
sink.Init();
|
|
||||||
sink.OpenSink();
|
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
geo_->CombineWithGeometry(
|
geo_->CombineWithGeometry(
|
||||||
input.geo_.get(),
|
input.geo_.get(),
|
||||||
|
|
@ -108,41 +104,18 @@ namespace kiwano
|
||||||
sink.GetGeometrySink().get()
|
sink.GetGeometrySink().get()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
sink.CloseSink();
|
|
||||||
return sink.GetGeometry();
|
|
||||||
}
|
}
|
||||||
return Geometry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Geometry Geometry::Combine(Vector<Geometry> const& geos, Vector<CombineMode> const& modes, Vector<Matrix3x2> const& matrixs)
|
Geometry Geometry::CombineWith(Geometry input, CombineMode mode, Matrix3x2 const& input_matrix) const
|
||||||
{
|
{
|
||||||
if ((geos.size() == (modes.size() + 1) || modes.size() == 1)
|
GeometrySink sink;
|
||||||
&& (geos.size() == (matrixs.size() + 1) || matrixs.size() == 1))
|
sink.Open();
|
||||||
{
|
|
||||||
GeometrySink sink;
|
|
||||||
sink.Init();
|
|
||||||
sink.OpenSink();
|
|
||||||
|
|
||||||
for (size_t i = 0; i < geos.size() - 1; i++)
|
CombineWith(sink, input, mode, input_matrix);
|
||||||
{
|
|
||||||
CombineMode mode = (modes.size() == 1) ? modes[0] : modes[i];
|
|
||||||
const Matrix3x2& matrix = (matrixs.size() == 1) ? matrixs[0] : matrixs[i];
|
|
||||||
|
|
||||||
ThrowIfFailed(
|
sink.Close();
|
||||||
geos[i].geo_->CombineWithGeometry(
|
return sink.GetGeometry();
|
||||||
geos[i + 1].geo_.get(),
|
|
||||||
D2D1_COMBINE_MODE(mode),
|
|
||||||
DX::ConvertToMatrix3x2F(matrix),
|
|
||||||
sink.GetGeometrySink().get()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sink.CloseSink();
|
|
||||||
return sink.GetGeometry();
|
|
||||||
}
|
|
||||||
return Geometry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Geometry::ComputeArea() const
|
float Geometry::ComputeArea() const
|
||||||
|
|
@ -214,13 +187,16 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeometrySink::~GeometrySink()
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
GeometrySink& GeometrySink::BeginPath(Point const& begin_pos)
|
GeometrySink& GeometrySink::BeginPath(Point const& begin_pos)
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
|
|
||||||
if (!sink_)
|
if (!sink_)
|
||||||
{
|
{
|
||||||
OpenSink();
|
Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
sink_->BeginFigure(DX::ConvertToPoint2F(begin_pos), D2D1_FIGURE_BEGIN_FILLED);
|
sink_->BeginFigure(DX::ConvertToPoint2F(begin_pos), D2D1_FIGURE_BEGIN_FILLED);
|
||||||
|
|
@ -233,7 +209,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
|
sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
|
||||||
|
|
||||||
CloseSink();
|
Close();
|
||||||
}
|
}
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
@ -312,15 +288,17 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometrySink::OpenSink()
|
void GeometrySink::Open()
|
||||||
{
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
if (!sink_)
|
if (!sink_)
|
||||||
{
|
{
|
||||||
ThrowIfFailed(path_geo_->Open(&sink_));
|
ThrowIfFailed(path_geo_->Open(&sink_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometrySink::CloseSink()
|
void GeometrySink::Close()
|
||||||
{
|
{
|
||||||
if (sink_)
|
if (sink_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
class GeometrySink;
|
||||||
|
|
||||||
// 섯부竟
|
// 섯부竟
|
||||||
class KGE_API Geometry
|
class KGE_API Geometry
|
||||||
|
|
@ -72,19 +73,19 @@ namespace kiwano
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// 莉북섯부竟
|
// 莉북섯부竟
|
||||||
Geometry CombineWith(
|
void CombineWith(
|
||||||
|
GeometrySink& sink,
|
||||||
Geometry input,
|
Geometry input,
|
||||||
CombineMode mode,
|
CombineMode mode,
|
||||||
Matrix3x2 const& input_matrix = Matrix3x2()
|
Matrix3x2 const& input_matrix = Matrix3x2()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// 组合多个几何体
|
// 组合几何体
|
||||||
// 参数 modes 和 matrixs 的数量应为 1 或 geos 的数量减一
|
Geometry CombineWith(
|
||||||
static Geometry Combine(
|
Geometry input,
|
||||||
Vector<Geometry> const& geos,
|
CombineMode mode,
|
||||||
Vector<CombineMode> const& modes,
|
Matrix3x2 const& input_matrix = Matrix3x2()
|
||||||
Vector<Matrix3x2> const& matrixs = { Matrix3x2() }
|
) const;
|
||||||
);
|
|
||||||
|
|
||||||
// 눼쉔殮窟
|
// 눼쉔殮窟
|
||||||
static Geometry CreateLine(
|
static Geometry CreateLine(
|
||||||
|
|
@ -133,6 +134,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeometrySink();
|
GeometrySink();
|
||||||
|
~GeometrySink();
|
||||||
|
|
||||||
// 역迦警속쨌쓺
|
// 역迦警속쨌쓺
|
||||||
GeometrySink& BeginPath(
|
GeometrySink& BeginPath(
|
||||||
|
|
@ -179,6 +181,12 @@ namespace kiwano
|
||||||
// 삿혤<EC82BF>냥쨌쓺섯부竟
|
// 삿혤<EC82BF>냥쨌쓺섯부竟
|
||||||
Geometry GetGeometry();
|
Geometry GetGeometry();
|
||||||
|
|
||||||
|
// 打开流
|
||||||
|
void Open();
|
||||||
|
|
||||||
|
// 关闭流
|
||||||
|
void Close();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline ComPtr<ID2D1PathGeometry> GetPathGeometry() const { return path_geo_; }
|
inline ComPtr<ID2D1PathGeometry> GetPathGeometry() const { return path_geo_; }
|
||||||
|
|
||||||
|
|
@ -190,10 +198,6 @@ namespace kiwano
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
void OpenSink();
|
|
||||||
|
|
||||||
void CloseSink();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComPtr<ID2D1PathGeometry> path_geo_;
|
ComPtr<ID2D1PathGeometry> path_geo_;
|
||||||
ComPtr<ID2D1GeometrySink> sink_;
|
ComPtr<ID2D1GeometrySink> sink_;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawGeometry(Geometry const& geometry, float stroke_width, StrokeStyle stroke) const
|
void RenderTarget::DrawGeometry(Geometry const& geometry, float stroke_width, StrokeStyle stroke)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -136,7 +136,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::FillGeometry(Geometry const& geometry) const
|
void RenderTarget::FillGeometry(Geometry const& geometry)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -157,7 +157,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawLine(Point const& point1, Point const& point2, float stroke_width, StrokeStyle stroke) const
|
void RenderTarget::DrawLine(Point const& point1, Point const& point2, float stroke_width, StrokeStyle stroke)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -181,7 +181,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawRectangle(Rect const& rect, float stroke_width, StrokeStyle stroke) const
|
void RenderTarget::DrawRectangle(Rect const& rect, float stroke_width, StrokeStyle stroke)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::FillRectangle(Rect const& rect) const
|
void RenderTarget::FillRectangle(Rect const& rect)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -226,7 +226,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawRoundedRectangle(Rect const& rect, Vec2 const& radius, float stroke_width, StrokeStyle stroke) const
|
void RenderTarget::DrawRoundedRectangle(Rect const& rect, Vec2 const& radius, float stroke_width, StrokeStyle stroke)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -253,7 +253,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::FillRoundedRectangle(Rect const& rect, Vec2 const& radius) const
|
void RenderTarget::FillRoundedRectangle(Rect const& rect, Vec2 const& radius)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -278,7 +278,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawEllipse(Point const& center, Vec2 const& radius, float stroke_width, StrokeStyle stroke) const
|
void RenderTarget::DrawEllipse(Point const& center, Vec2 const& radius, float stroke_width, StrokeStyle stroke)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -305,7 +305,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::FillEllipse(Point const& center, Vec2 const& radius) const
|
void RenderTarget::FillEllipse(Point const& center, Vec2 const& radius)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_ || !current_brush_)
|
if (!render_target_ || !current_brush_)
|
||||||
|
|
@ -330,12 +330,12 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawTexture(Texture const& texture, Rect const& src_rect, Rect const& dest_rect) const
|
void RenderTarget::DrawTexture(Texture const& texture, Rect const& src_rect, Rect const& dest_rect)
|
||||||
{
|
{
|
||||||
DrawTexture(texture, &src_rect, &dest_rect);
|
DrawTexture(texture, &src_rect, &dest_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawTexture(Texture const& texture, const Rect* src_rect, const Rect* dest_rect) const
|
void RenderTarget::DrawTexture(Texture const& texture, const Rect* src_rect, const Rect* dest_rect)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!render_target_)
|
if (!render_target_)
|
||||||
|
|
@ -363,7 +363,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::DrawTextLayout(TextLayout const& layout, Point const& offset) const
|
void RenderTarget::DrawTextLayout(TextLayout const& layout, Point const& offset)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (!text_renderer_)
|
if (!text_renderer_)
|
||||||
|
|
@ -393,7 +393,7 @@ namespace kiwano
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTarget::CreateLayer(LayerArea& layer) const
|
void RenderTarget::CreateLayer(LayerArea& layer)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
|
@ -540,7 +540,7 @@ namespace kiwano
|
||||||
return global_transform_;
|
return global_transform_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<ID2D1StrokeStyle> RenderTarget::GetStrokeStyle(StrokeStyle style) const
|
ComPtr<ID2D1StrokeStyle> RenderTarget::GetStrokeStyle(StrokeStyle style)
|
||||||
{
|
{
|
||||||
switch (style)
|
switch (style)
|
||||||
{
|
{
|
||||||
|
|
@ -710,7 +710,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture TextureRenderTarget::GetOutput() const
|
Texture TextureRenderTarget::GetOutput()
|
||||||
{
|
{
|
||||||
HRESULT hr = E_FAIL;
|
HRESULT hr = E_FAIL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,75 +52,75 @@ namespace kiwano
|
||||||
|
|
||||||
void CreateLayer(
|
void CreateLayer(
|
||||||
LayerArea& layer
|
LayerArea& layer
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawGeometry(
|
void DrawGeometry(
|
||||||
Geometry const& geometry,
|
Geometry const& geometry,
|
||||||
float stroke_width,
|
float stroke_width,
|
||||||
StrokeStyle stroke = StrokeStyle::Miter
|
StrokeStyle stroke = StrokeStyle::Miter
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void FillGeometry(
|
void FillGeometry(
|
||||||
Geometry const& geometry
|
Geometry const& geometry
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawLine(
|
void DrawLine(
|
||||||
Point const& point1,
|
Point const& point1,
|
||||||
Point const& point2,
|
Point const& point2,
|
||||||
float stroke_width,
|
float stroke_width,
|
||||||
StrokeStyle stroke = StrokeStyle::Miter
|
StrokeStyle stroke = StrokeStyle::Miter
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawRectangle(
|
void DrawRectangle(
|
||||||
Rect const& rect,
|
Rect const& rect,
|
||||||
float stroke_width,
|
float stroke_width,
|
||||||
StrokeStyle stroke = StrokeStyle::Miter
|
StrokeStyle stroke = StrokeStyle::Miter
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void FillRectangle(
|
void FillRectangle(
|
||||||
Rect const& rect
|
Rect const& rect
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawRoundedRectangle(
|
void DrawRoundedRectangle(
|
||||||
Rect const& rect,
|
Rect const& rect,
|
||||||
Vec2 const& radius,
|
Vec2 const& radius,
|
||||||
float stroke_width,
|
float stroke_width,
|
||||||
StrokeStyle stroke = StrokeStyle::Miter
|
StrokeStyle stroke = StrokeStyle::Miter
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void FillRoundedRectangle(
|
void FillRoundedRectangle(
|
||||||
Rect const& rect,
|
Rect const& rect,
|
||||||
Vec2 const& radius
|
Vec2 const& radius
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawEllipse(
|
void DrawEllipse(
|
||||||
Point const& center,
|
Point const& center,
|
||||||
Vec2 const& radius,
|
Vec2 const& radius,
|
||||||
float stroke_width,
|
float stroke_width,
|
||||||
StrokeStyle stroke = StrokeStyle::Miter
|
StrokeStyle stroke = StrokeStyle::Miter
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void FillEllipse(
|
void FillEllipse(
|
||||||
Point const& center,
|
Point const& center,
|
||||||
Vec2 const& radius
|
Vec2 const& radius
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawTexture(
|
void DrawTexture(
|
||||||
Texture const& texture,
|
Texture const& texture,
|
||||||
Rect const& src_rect,
|
Rect const& src_rect,
|
||||||
Rect const& dest_rect
|
Rect const& dest_rect
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawTexture(
|
void DrawTexture(
|
||||||
Texture const& texture,
|
Texture const& texture,
|
||||||
const Rect* src_rect = nullptr,
|
const Rect* src_rect = nullptr,
|
||||||
const Rect* dest_rect = nullptr
|
const Rect* dest_rect = nullptr
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void DrawTextLayout(
|
void DrawTextLayout(
|
||||||
TextLayout const& layout,
|
TextLayout const& layout,
|
||||||
Point const& offset = Point{}
|
Point const& offset = Point{}
|
||||||
) const;
|
);
|
||||||
|
|
||||||
void PushClipRect(
|
void PushClipRect(
|
||||||
Rect const& clip_rect
|
Rect const& clip_rect
|
||||||
|
|
@ -206,7 +206,7 @@ namespace kiwano
|
||||||
|
|
||||||
inline ComPtr<ITextRenderer> GetTextRenderer() const { KGE_ASSERT(text_renderer_); return text_renderer_; }
|
inline ComPtr<ITextRenderer> GetTextRenderer() const { KGE_ASSERT(text_renderer_); return text_renderer_; }
|
||||||
|
|
||||||
ComPtr<ID2D1StrokeStyle> GetStrokeStyle(StrokeStyle style) const;
|
ComPtr<ID2D1StrokeStyle> GetStrokeStyle(StrokeStyle style);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RenderTarget();
|
RenderTarget();
|
||||||
|
|
@ -241,6 +241,6 @@ namespace kiwano
|
||||||
public:
|
public:
|
||||||
TextureRenderTarget();
|
TextureRenderTarget();
|
||||||
|
|
||||||
Texture GetOutput() const;
|
Texture GetOutput();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,9 +192,9 @@ namespace kiwano
|
||||||
|
|
||||||
inline Color const& GetClearColor() const { return clear_color_; }
|
inline Color const& GetClearColor() const { return clear_color_; }
|
||||||
|
|
||||||
inline ID2DDeviceResources* GetD2DDeviceResources() const { KGE_ASSERT(d2d_res_); return d2d_res_.get(); }
|
inline ID2DDeviceResources* GetD2DDeviceResources() { KGE_ASSERT(d2d_res_); return d2d_res_.get(); }
|
||||||
|
|
||||||
inline ID3DDeviceResources* GetD3DDeviceResources() const { KGE_ASSERT(d3d_res_); return d3d_res_.get(); }
|
inline ID3DDeviceResources* GetD3DDeviceResources() { KGE_ASSERT(d3d_res_); return d3d_res_.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer();
|
Renderer();
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,6 @@ namespace kiwano
|
||||||
protected:
|
protected:
|
||||||
TextStyle style_;
|
TextStyle style_;
|
||||||
TextFormat text_format_;
|
TextFormat text_format_;
|
||||||
ComPtr<IDWriteTextLayout> text_layout_;
|
mutable ComPtr<IDWriteTextLayout> text_layout_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,20 +66,20 @@ namespace kiwano
|
||||||
HRESULT CreateTextFormat(
|
HRESULT CreateTextFormat(
|
||||||
_Out_ ComPtr<IDWriteTextFormat>& text_format,
|
_Out_ ComPtr<IDWriteTextFormat>& text_format,
|
||||||
_In_ Font const& font
|
_In_ Font const& font
|
||||||
) const override;
|
) override;
|
||||||
|
|
||||||
HRESULT CreateTextLayout(
|
HRESULT CreateTextLayout(
|
||||||
_Out_ ComPtr<IDWriteTextLayout>& text_layout,
|
_Out_ ComPtr<IDWriteTextLayout>& text_layout,
|
||||||
_In_ String const& text,
|
_In_ String const& text,
|
||||||
_In_ ComPtr<IDWriteTextFormat> const& text_format
|
_In_ ComPtr<IDWriteTextFormat> text_format
|
||||||
) const override;
|
) override;
|
||||||
|
|
||||||
HRESULT SetD2DDevice(
|
HRESULT SetD2DDevice(
|
||||||
_In_ ComPtr<ID2D1Device> const& device
|
_In_ ComPtr<ID2D1Device> device
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
void SetTargetBitmap(
|
void SetTargetBitmap(
|
||||||
_In_ ComPtr<ID2D1Bitmap1> const& target
|
_In_ ComPtr<ID2D1Bitmap1> target
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
void DiscardResources() override;
|
void DiscardResources() override;
|
||||||
|
|
@ -298,7 +298,7 @@ namespace kiwano
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT D2DDeviceResources::SetD2DDevice(_In_ ComPtr<ID2D1Device> const& device)
|
HRESULT D2DDeviceResources::SetD2DDevice(_In_ ComPtr<ID2D1Device> device)
|
||||||
{
|
{
|
||||||
ComPtr<ID2D1DeviceContext> device_ctx;
|
ComPtr<ID2D1DeviceContext> device_ctx;
|
||||||
|
|
||||||
|
|
@ -317,7 +317,7 @@ namespace kiwano
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D2DDeviceResources::SetTargetBitmap(_In_ ComPtr<ID2D1Bitmap1> const& target)
|
void D2DDeviceResources::SetTargetBitmap(_In_ ComPtr<ID2D1Bitmap1> target)
|
||||||
{
|
{
|
||||||
target_bitmap_ = target;
|
target_bitmap_ = target;
|
||||||
if (device_context_)
|
if (device_context_)
|
||||||
|
|
@ -435,7 +435,7 @@ namespace kiwano
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT D2DDeviceResources::CreateTextFormat(_Out_ ComPtr<IDWriteTextFormat> & text_format, _In_ Font const & font) const
|
HRESULT D2DDeviceResources::CreateTextFormat(_Out_ ComPtr<IDWriteTextFormat> & text_format, _In_ Font const & font)
|
||||||
{
|
{
|
||||||
if (!dwrite_factory_)
|
if (!dwrite_factory_)
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
@ -460,7 +460,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT D2DDeviceResources::CreateTextLayout(_Out_ ComPtr<IDWriteTextLayout>& text_layout, _In_ String const& text,
|
HRESULT D2DDeviceResources::CreateTextLayout(_Out_ ComPtr<IDWriteTextLayout>& text_layout, _In_ String const& text,
|
||||||
_In_ ComPtr<IDWriteTextFormat> const& text_format) const
|
_In_ ComPtr<IDWriteTextFormat> text_format)
|
||||||
{
|
{
|
||||||
if (!dwrite_factory_)
|
if (!dwrite_factory_)
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
|
||||||
|
|
@ -217,34 +217,34 @@ namespace kiwano
|
||||||
virtual HRESULT CreateTextFormat(
|
virtual HRESULT CreateTextFormat(
|
||||||
_Out_ ComPtr<IDWriteTextFormat>& text_format,
|
_Out_ ComPtr<IDWriteTextFormat>& text_format,
|
||||||
_In_ Font const& font
|
_In_ Font const& font
|
||||||
) const = 0;
|
) = 0;
|
||||||
|
|
||||||
virtual HRESULT CreateTextLayout(
|
virtual HRESULT CreateTextLayout(
|
||||||
_Out_ ComPtr<IDWriteTextLayout>& text_layout,
|
_Out_ ComPtr<IDWriteTextLayout>& text_layout,
|
||||||
_In_ String const& text,
|
_In_ String const& text,
|
||||||
_In_ ComPtr<IDWriteTextFormat> const& text_format
|
_In_ ComPtr<IDWriteTextFormat> text_format
|
||||||
) const = 0;
|
) = 0;
|
||||||
|
|
||||||
virtual HRESULT SetD2DDevice(
|
virtual HRESULT SetD2DDevice(
|
||||||
_In_ ComPtr<ID2D1Device> const& device
|
_In_ ComPtr<ID2D1Device> device
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
virtual void SetTargetBitmap(
|
virtual void SetTargetBitmap(
|
||||||
_In_ ComPtr<ID2D1Bitmap1> const& target
|
_In_ ComPtr<ID2D1Bitmap1> target
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
virtual void DiscardResources() = 0;
|
virtual void DiscardResources() = 0;
|
||||||
|
|
||||||
inline ID2D1Factory1* GetFactory() const { KGE_ASSERT(factory_); return factory_.get(); }
|
inline ID2D1Factory1* GetFactory() { KGE_ASSERT(factory_); return factory_.get(); }
|
||||||
inline IWICImagingFactory* GetWICImagingFactory() const { KGE_ASSERT(imaging_factory_); return imaging_factory_.get(); }
|
inline IWICImagingFactory* GetWICImagingFactory() { KGE_ASSERT(imaging_factory_); return imaging_factory_.get(); }
|
||||||
inline IDWriteFactory* GetDWriteFactory() const { KGE_ASSERT(dwrite_factory_); return dwrite_factory_.get(); }
|
inline IDWriteFactory* GetDWriteFactory() { KGE_ASSERT(dwrite_factory_); return dwrite_factory_.get(); }
|
||||||
inline ID2D1Device* GetDevice() const { KGE_ASSERT(device_); return device_.get(); }
|
inline ID2D1Device* GetDevice() { KGE_ASSERT(device_); return device_.get(); }
|
||||||
inline ID2D1DeviceContext* GetDeviceContext() const { KGE_ASSERT(device_context_); return device_context_.get(); }
|
inline ID2D1DeviceContext* GetDeviceContext() { KGE_ASSERT(device_context_); return device_context_.get(); }
|
||||||
inline ID2D1Bitmap1* GetTargetBitmap() const { KGE_ASSERT(target_bitmap_); return target_bitmap_.get(); }
|
inline ID2D1Bitmap1* GetTargetBitmap() { KGE_ASSERT(target_bitmap_); return target_bitmap_.get(); }
|
||||||
|
|
||||||
inline ID2D1StrokeStyle* GetMiterStrokeStyle() const { KGE_ASSERT(miter_stroke_style_); return miter_stroke_style_.get(); }
|
inline ID2D1StrokeStyle* GetMiterStrokeStyle() { KGE_ASSERT(miter_stroke_style_); return miter_stroke_style_.get(); }
|
||||||
inline ID2D1StrokeStyle* GetBevelStrokeStyle() const { KGE_ASSERT(bevel_stroke_style_); return bevel_stroke_style_.get(); }
|
inline ID2D1StrokeStyle* GetBevelStrokeStyle() { KGE_ASSERT(bevel_stroke_style_); return bevel_stroke_style_.get(); }
|
||||||
inline ID2D1StrokeStyle* GetRoundStrokeStyle() const { KGE_ASSERT(round_stroke_style_); return round_stroke_style_.get(); }
|
inline ID2D1StrokeStyle* GetRoundStrokeStyle() { KGE_ASSERT(round_stroke_style_); return round_stroke_style_.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComPtr<ID2D1Factory1> factory_;
|
ComPtr<ID2D1Factory1> factory_;
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ namespace kiwano
|
||||||
public:
|
public:
|
||||||
static HRESULT Create(ID3D10DeviceResources** device_resources, ID2DDeviceResources* d2d_device_res, HWND hwnd);
|
static HRESULT Create(ID3D10DeviceResources** device_resources, ID2DDeviceResources* d2d_device_res, HWND hwnd);
|
||||||
|
|
||||||
inline ID3D10Device* GetDevice() const { KGE_ASSERT(device_); return device_.get(); }
|
inline ID3D10Device* GetDevice() { KGE_ASSERT(device_); return device_.get(); }
|
||||||
inline ID3D10RenderTargetView* GetRenderTargetView() const { KGE_ASSERT(rt_view_); return rt_view_.get(); }
|
inline ID3D10RenderTargetView* GetRenderTargetView() { KGE_ASSERT(rt_view_); return rt_view_.get(); }
|
||||||
inline ID3D10DepthStencilView* GetDepthStencilView() const { KGE_ASSERT(ds_view_); return ds_view_.get(); }
|
inline ID3D10DepthStencilView* GetDepthStencilView() { KGE_ASSERT(ds_view_); return ds_view_.get(); }
|
||||||
inline IDXGIFactory* GetDXGIFactory() const { KGE_ASSERT(dxgi_factory_); return dxgi_factory_.get(); }
|
inline IDXGIFactory* GetDXGIFactory() { KGE_ASSERT(dxgi_factory_); return dxgi_factory_.get(); }
|
||||||
inline IDXGISwapChain* GetDXGISwapChain() const { KGE_ASSERT(dxgi_swap_chain_); return dxgi_swap_chain_.get(); }
|
inline IDXGISwapChain* GetDXGISwapChain() { KGE_ASSERT(dxgi_swap_chain_); return dxgi_swap_chain_.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComPtr<ID3D10Device> device_;
|
ComPtr<ID3D10Device> device_;
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ namespace kiwano
|
||||||
public:
|
public:
|
||||||
static HRESULT Create(ID3D11DeviceResources** device_resources, ID2DDeviceResources* d2d_device_res, HWND hwnd);
|
static HRESULT Create(ID3D11DeviceResources** device_resources, ID2DDeviceResources* d2d_device_res, HWND hwnd);
|
||||||
|
|
||||||
inline ID3D11Device* GetDevice() const { KGE_ASSERT(device_); return device_.get(); }
|
inline ID3D11Device* GetDevice() { KGE_ASSERT(device_); return device_.get(); }
|
||||||
inline ID3D11DeviceContext* GetDeviceContext() const { KGE_ASSERT(device_context_); return device_context_.get(); }
|
inline ID3D11DeviceContext* GetDeviceContext() { KGE_ASSERT(device_context_); return device_context_.get(); }
|
||||||
inline ID3D11RenderTargetView* GetRenderTargetView() const { KGE_ASSERT(rt_view_); return rt_view_.get(); }
|
inline ID3D11RenderTargetView* GetRenderTargetView() { KGE_ASSERT(rt_view_); return rt_view_.get(); }
|
||||||
inline ID3D11DepthStencilView* GetDepthStencilView() const { KGE_ASSERT(ds_view_); return ds_view_.get(); }
|
inline ID3D11DepthStencilView* GetDepthStencilView() { KGE_ASSERT(ds_view_); return ds_view_.get(); }
|
||||||
inline IDXGIFactory* GetDXGIFactory() const { KGE_ASSERT(dxgi_factory_); return dxgi_factory_.get(); }
|
inline IDXGIFactory* GetDXGIFactory() { KGE_ASSERT(dxgi_factory_); return dxgi_factory_.get(); }
|
||||||
inline IDXGISwapChain* GetDXGISwapChain() const { KGE_ASSERT(dxgi_swap_chain_); return dxgi_swap_chain_.get(); }
|
inline IDXGISwapChain* GetDXGISwapChain() { KGE_ASSERT(dxgi_swap_chain_); return dxgi_swap_chain_.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComPtr<ID3D11Device> device_;
|
ComPtr<ID3D11Device> device_;
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
enabled_ = enabled;
|
enabled_ = enabled;
|
||||||
|
|
||||||
for (const auto& button : buttons_)
|
for (auto& button : buttons_)
|
||||||
{
|
{
|
||||||
button->SetEnabled(enabled);
|
button->SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ namespace kiwano
|
||||||
auto iter = object_cache_.find(id);
|
auto iter = object_cache_.find(id);
|
||||||
if (iter == object_cache_.end())
|
if (iter == object_cache_.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return dynamic_cast<_Ty*>((*iter).second.get());
|
return const_cast<_Ty*>(dynamic_cast<const _Ty*>((*iter).second.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue