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

@ -12,11 +12,14 @@
// Next frame, that one is scanned out and the other one gets the copy. = double buffering.
// ---------------------------------------------------------------------------------------------
#include "VideoCommon/RenderBase.h"
#include <cinttypes>
#include <cmath>
#include <memory>
#include <mutex>
#include <string>
#include <tuple>
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
@ -48,7 +51,6 @@
#include "VideoCommon/ImageWrite.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/PostProcessing.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/TextureCacheBase.h"
#include "VideoCommon/TextureDecoder.h"
@ -509,8 +511,8 @@ TargetRectangle Renderer::CalculateFrameDumpDrawRectangle()
}
// Grab the dimensions of the EFB textures, we scale either of these depending on the ratio.
unsigned int efb_width, efb_height;
g_framebuffer_manager->GetTargetSize(&efb_width, &efb_height);
u32 efb_width, efb_height;
std::tie(efb_width, efb_height) = g_framebuffer_manager->GetTargetSize();
float draw_width, draw_height;
std::tie(draw_width, draw_height) = ScaleToDisplayAspectRatio(efb_width, efb_height);