FramebufferManagerBase: Get rid of explicit delete and new

This commit is contained in:
Lioncash
2015-12-21 14:11:01 -05:00
parent 9039cc5860
commit f448c6e291
6 changed files with 37 additions and 38 deletions

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <memory>
#include "Core/HW/Memmap.h"
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DUtil.h"
@ -13,7 +15,8 @@
#include "VideoBackends/D3D/XFBEncoder.h"
#include "VideoCommon/VideoConfig.h"
namespace DX11 {
namespace DX11
{
static XFBEncoder s_xfbEncoder;
@ -176,9 +179,9 @@ void FramebufferManager::CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight,
s_xfbEncoder.Encode(dst, fbStride/2, fbHeight, sourceRc, Gamma);
}
XFBSourceBase* FramebufferManager::CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers)
std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers)
{
return new XFBSource(D3DTexture2D::Create(target_width, target_height,
return std::make_unique<XFBSource>(D3DTexture2D::Create(target_width, target_height,
(D3D11_BIND_FLAG)(D3D11_BIND_RENDER_TARGET|D3D11_BIND_SHADER_RESOURCE),
D3D11_USAGE_DEFAULT, DXGI_FORMAT_R8G8B8A8_UNORM, 1, layers), layers);
}

View File

@ -4,13 +4,14 @@
#pragma once
#include "d3d11.h"
#include <d3d11.h>
#include <memory>
#include "VideoBackends/D3D/D3DTexture.h"
#include "VideoCommon/FramebufferManagerBase.h"
namespace DX11 {
namespace DX11
{
// On the GameCube, the game sends a request for the graphics processor to
// transfer its internal EFB (Embedded Framebuffer) to an area in GameCube RAM
// called the XFB (External Framebuffer). The size and location of the XFB is
@ -80,7 +81,7 @@ public:
}
private:
XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override;
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override;
void GetTargetSize(unsigned int *width, unsigned int *height) override;
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma) override;

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <memory>
#include "Common/Common.h"
#include "Common/CommonFuncs.h"
#include "Common/GL/GLInterfaceBase.h"
@ -623,7 +625,7 @@ void XFBSource::CopyEFB(float Gamma)
}
XFBSourceBase* FramebufferManager::CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers)
std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers)
{
GLuint texture;
@ -634,7 +636,7 @@ XFBSourceBase* FramebufferManager::CreateXFBSource(unsigned int target_width, un
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, target_width, target_height, layers, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
return new XFBSource(texture, layers);
return std::make_unique<XFBSource>(texture, layers);
}
void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height)

View File

@ -4,11 +4,11 @@
#pragma once
#include "Common/GL/GLUtil.h"
#include <memory>
#include "Common/GL/GLUtil.h"
#include "VideoBackends/OGL/ProgramShaderCache.h"
#include "VideoBackends/OGL/Render.h"
#include "VideoCommon/FramebufferManagerBase.h"
// On the GameCube, the game sends a request for the graphics processor to
@ -95,7 +95,7 @@ public:
static void PokeEFB(EFBAccessType type, const std::vector<EfbPokeData>& data);
private:
XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override;
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override;
void GetTargetSize(unsigned int *width, unsigned int *height) override;
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma) override;