Skip to content
Permalink
Browse files

Fix some further static analysis warnings

  • Loading branch information...
hrydgard committed Jun 17, 2019
1 parent a0dc85a commit eb3faf5370ad514d3c5c2ad12cf2c5efabe36632
@@ -237,26 +237,24 @@ static bool ConvertPixelTo8888RGBA(GPUDebugBufferFormat fmt, u8 &r, u8 &g, u8 &b
}

const u8 *ConvertBufferToScreenshot(const GPUDebugBuffer &buf, bool alpha, u8 *&temp, u32 &w, u32 &h) {
int pixelSize = alpha ? 4 : 3;
size_t pixelSize = alpha ? 4 : 3;
GPUDebugBufferFormat nativeFmt = alpha ? GPU_DBG_FORMAT_8888 : GPU_DBG_FORMAT_888_RGB;

w = std::min(w, buf.GetStride());
h = std::min(h, buf.GetHeight());

// The temp buffer will be freed by the caller if set, and can be the return value.
if (buf.GetFlipped() || buf.GetFormat() != nativeFmt) {
temp = new u8[pixelSize * w * h];
} else {
temp = nullptr;
}
temp = nullptr;

const u8 *buffer = buf.GetData();
if (buf.GetFlipped() && buf.GetFormat() == nativeFmt) {
temp = new u8[pixelSize * w * h];
// Silly OpenGL reads upside down, we flip to another buffer for simplicity.
for (u32 y = 0; y < h; y++) {
memcpy(temp + y * w * pixelSize, buffer + (buf.GetHeight() - y - 1) * buf.GetStride() * pixelSize, w * pixelSize);
}
} else if (buf.GetFormat() < GPU_DBG_FORMAT_FLOAT && buf.GetFormat() != nativeFmt) {
temp = new u8[pixelSize * w * h];
// Let's boil it down to how we need to interpret the bits.
int baseFmt = buf.GetFormat() & ~(GPU_DBG_FORMAT_REVERSE_FLAG | GPU_DBG_FORMAT_BRSWAP_FLAG);
bool rev = (buf.GetFormat() & GPU_DBG_FORMAT_REVERSE_FLAG) != 0;
@@ -284,6 +282,7 @@ const u8 *ConvertBufferToScreenshot(const GPUDebugBuffer &buf, bool alpha, u8 *&
}
}
} else if (buf.GetFormat() != nativeFmt) {
temp = new u8[pixelSize * w * h];
bool flip = buf.GetFlipped();

// This is pretty inefficient.
@@ -168,7 +168,7 @@ struct GPUDebugBuffer {
u8 *data_ = nullptr;
u32 stride_ = 0;
u32 height_ = 0;
GPUDebugBufferFormat fmt_;
GPUDebugBufferFormat fmt_ = GPU_DBG_FORMAT_INVALID;
bool flipped_ = false;
};

@@ -156,7 +156,7 @@ void VulkanRenderManager::CreateBackbuffers() {
VkCommandBuffer cmdInit = GetInitCmd();

for (uint32_t i = 0; i < swapchainImageCount_; i++) {
SwapchainImageData sc_buffer;
SwapchainImageData sc_buffer{};
sc_buffer.image = swapchainImages[i];

VkImageViewCreateInfo color_image_view = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
@@ -190,7 +190,7 @@ class SliderPopupScreen : public PopupScreen {
std::string units_;
std::string negativeLabel_;
int *value_;
int sliderValue_;
int sliderValue_ = 0;
int minValue_;
int maxValue_;
int step_;
@@ -580,7 +580,7 @@ class SliderFloat : public Clickable {
float paddingLeft_;
float paddingRight_;
int repeat_;
int repeatCode_;
int repeatCode_ = 0;
};

// Basic button that modifies a bitfield based on the pressed status. Supports multitouch.
@@ -31,7 +31,7 @@ class WordWrapper {
// Position the current word starts at.
float x_ = 0.0f;
// Most recent width of word since last index.
float wordWidth_;
float wordWidth_ = 0.0f;
// Force the next word to cut partially and wrap.
bool forceEarlyWrap_ = false;
};

0 comments on commit eb3faf5

Please sign in to comment.
You can’t perform that action at this time.