FramebufferManagerBase: Return a std::pair from GetTargetSize

Keeps associated data together. It also eliminates the possibility of out
parameters not being initialized properly. For example, consider the
following example:

-- some FramebufferManager implementation --

void FBMgrImpl::GetTargetSize(u32* width, u32* height) override
{
  // Do nothing
}

-- somewhere else where the function is used --

u32 width, height;
framebuffer_manager_instance->GetTargetSize(&width, &height);

if (texture_width != width) <-- Uninitialized variable usage
{
  ...
}

It makes it much more obvious to spot any initialization issues, because
it requires something to be returned, as opposed to allowing an
implementation to just not do anything.
This commit is contained in:
Lioncash
2017-02-03 12:31:20 -05:00
parent 28357f16e2
commit c85e0a2586
13 changed files with 43 additions and 25 deletions

View File

@ -2,13 +2,15 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoBackends/D3D/FramebufferManager.h"
#include <memory>
#include "Common/CommonTypes.h"
#include "Core/HW/Memmap.h"
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DState.h"
#include "VideoBackends/D3D/D3DUtil.h"
#include "VideoBackends/D3D/FramebufferManager.h"
#include "VideoBackends/D3D/GeometryShaderCache.h"
#include "VideoBackends/D3D/PixelShaderCache.h"
#include "VideoBackends/D3D/Render.h"
@ -292,10 +294,9 @@ std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int
layers);
}
void FramebufferManager::GetTargetSize(unsigned int* width, unsigned int* height)
std::pair<u32, u32> FramebufferManager::GetTargetSize() const
{
*width = m_target_width;
*height = m_target_height;
return std::make_pair(m_target_width, m_target_height);
}
void XFBSource::DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight)