diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2015-12-21 22:48:13 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2015-12-21 22:48:13 +0100 |
| commit | 4c428ed01946ab3137b910d99494ba0ca77665c7 (patch) | |
| tree | f0da725626020383be61a57ab3a8f6ed41ef2142 /Source/Core/VideoCommon | |
| parent | 9039cc58606612ca9f14631d148b72cf6b13133f (diff) | |
| parent | f448c6e291cc4207e3978ff5510c66f0d4d8dd29 (diff) | |
Merge pull request #3372 from lioncash/framebuffer
FramebufferManagerBase: Get rid of explicit delete and new
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/FramebufferManagerBase.cpp | 35 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/FramebufferManagerBase.h | 10 |
2 files changed, 19 insertions, 26 deletions
diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/FramebufferManagerBase.cpp index b01c39a5f3..c6d5567d57 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.cpp +++ b/Source/Core/VideoCommon/FramebufferManagerBase.cpp @@ -3,15 +3,17 @@ // Refer to the license.txt file included. #include <algorithm> +#include <array> +#include <memory> #include "VideoCommon/FramebufferManagerBase.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/VideoConfig.h" FramebufferManagerBase *g_framebuffer_manager; -XFBSourceBase *FramebufferManagerBase::m_realXFBSource; // Only used in Real XFB mode +std::unique_ptr<XFBSourceBase> FramebufferManagerBase::m_realXFBSource; // Only used in Real XFB mode FramebufferManagerBase::VirtualXFBListType FramebufferManagerBase::m_virtualXFBList; // Only used in Virtual XFB mode -const XFBSourceBase* FramebufferManagerBase::m_overlappingXFBArray[MAX_VIRTUAL_XFB]; +std::array<const XFBSourceBase*, FramebufferManagerBase::MAX_VIRTUAL_XFB> FramebufferManagerBase::m_overlappingXFBArray; unsigned int FramebufferManagerBase::s_last_xfb_width = 1; unsigned int FramebufferManagerBase::s_last_xfb_height = 1; @@ -20,21 +22,16 @@ unsigned int FramebufferManagerBase::m_EFBLayers = 1; FramebufferManagerBase::FramebufferManagerBase() { - m_realXFBSource = nullptr; - - // can't hurt - memset(m_overlappingXFBArray, 0, sizeof(m_overlappingXFBArray)); + // Can't hurt + m_overlappingXFBArray.fill(nullptr); } FramebufferManagerBase::~FramebufferManagerBase() { - for (VirtualXFB& vxfb : m_virtualXFBList) - { - delete vxfb.xfbSource; - } + // Necessary, as these are static members + // (they really shouldn't be and should be refactored at some point). m_virtualXFBList.clear(); - - delete m_realXFBSource; + m_realXFBSource.reset(); } const XFBSourceBase* const* FramebufferManagerBase::GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCountP) @@ -54,10 +51,7 @@ const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr // recreate if needed if (m_realXFBSource && (m_realXFBSource->texWidth != fbWidth || m_realXFBSource->texHeight != fbHeight)) - { - delete m_realXFBSource; - m_realXFBSource = nullptr; - } + m_realXFBSource.reset(); if (!m_realXFBSource && g_framebuffer_manager) m_realXFBSource = g_framebuffer_manager->CreateXFBSource(fbWidth, fbHeight, 1); @@ -83,7 +77,7 @@ const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr // Decode YUYV data from GameCube RAM m_realXFBSource->DecodeToTexture(xfbAddr, fbWidth, fbHeight); - m_overlappingXFBArray[0] = m_realXFBSource; + m_overlappingXFBArray[0] = m_realXFBSource.get(); return &m_overlappingXFBArray[0]; } @@ -109,7 +103,7 @@ const XFBSourceBase* const* FramebufferManagerBase::GetVirtualXFBSource(u32 xfbA if (AddressRangesOverlap(srcLower, srcUpper, dstLower, dstUpper)) { - m_overlappingXFBArray[xfbCount] = vxfb->xfbSource; + m_overlappingXFBArray[xfbCount] = vxfb->xfbSource.get(); ++xfbCount; } } @@ -163,10 +157,7 @@ void FramebufferManagerBase::CopyToVirtualXFB(u32 xfbAddr, u32 fbStride, u32 fbH // recreate if needed if (vxfb->xfbSource && (vxfb->xfbSource->texWidth != target_width || vxfb->xfbSource->texHeight != target_height)) - { - delete vxfb->xfbSource; - vxfb->xfbSource = nullptr; - } + vxfb->xfbSource.reset(); if (!vxfb->xfbSource) { diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.h b/Source/Core/VideoCommon/FramebufferManagerBase.h index 6127037268..078652feb5 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.h +++ b/Source/Core/VideoCommon/FramebufferManagerBase.h @@ -4,7 +4,9 @@ #pragma once +#include <array> #include <list> +#include <memory> #include "VideoCommon/VideoCommon.h" @@ -70,7 +72,7 @@ protected: u32 xfbWidth = 0; u32 xfbHeight = 0; - XFBSourceBase* xfbSource = nullptr; + std::unique_ptr<XFBSourceBase> xfbSource; }; typedef std::list<VirtualXFB> VirtualXFBListType; @@ -78,7 +80,7 @@ protected: static unsigned int m_EFBLayers; private: - virtual XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) = 0; + virtual std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) = 0; // TODO: figure out why OGL is different for this guy virtual void GetTargetSize(unsigned int *width, unsigned int *height) = 0; @@ -93,10 +95,10 @@ private: static const XFBSourceBase* const* GetRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCount); static const XFBSourceBase* const* GetVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCount); - static XFBSourceBase *m_realXFBSource; // Only used in Real XFB mode + static std::unique_ptr<XFBSourceBase> m_realXFBSource; // Only used in Real XFB mode static VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode - static const XFBSourceBase* m_overlappingXFBArray[MAX_VIRTUAL_XFB]; + static std::array<const XFBSourceBase*, MAX_VIRTUAL_XFB> m_overlappingXFBArray; static unsigned int s_last_xfb_width; static unsigned int s_last_xfb_height; |
