EOL fixes

This commit is contained in:
elasota
2019-12-27 14:17:53 -05:00
parent 3fc9f587d5
commit 88fe873bbe
2 changed files with 128 additions and 128 deletions

View File

@@ -1,72 +1,72 @@
#include "QDPixMap.h" #include "QDPixMap.h"
#include "CoreDefs.h" #include "CoreDefs.h"
#include <assert.h> #include <assert.h>
namespace PortabilityLayer namespace PortabilityLayer
{ {
PixMapImpl::PixMapImpl(int16_t left, int16_t top, uint16_t width, uint16_t height, GpPixelFormat_t pixelFormat) PixMapImpl::PixMapImpl(int16_t left, int16_t top, uint16_t width, uint16_t height, GpPixelFormat_t pixelFormat)
: m_left(left) : m_left(left)
, m_top(top) , m_top(top)
, m_width(width) , m_width(width)
, m_height(height) , m_height(height)
, m_dataCapacity(0) , m_dataCapacity(0)
{ {
const Rect rect = Rect::Create(top, left, static_cast<uint16_t>(top + height), static_cast<uint16_t>(left + width)); const Rect rect = Rect::Create(top, left, static_cast<uint16_t>(top + height), static_cast<uint16_t>(left + width));
const size_t pitch = PitchForWidth(width, pixelFormat); const size_t pitch = PitchForWidth(width, pixelFormat);
void *dataPtr = reinterpret_cast<uint8_t*>(this) + AlignedSize(); void *dataPtr = reinterpret_cast<uint8_t*>(this) + AlignedSize();
m_dataCapacity = PitchForWidth(width, pixelFormat) * height; m_dataCapacity = PitchForWidth(width, pixelFormat) * height;
static_cast<PixMap*>(this)->Init(rect, pixelFormat, PitchForWidth(width, pixelFormat), dataPtr); static_cast<PixMap*>(this)->Init(rect, pixelFormat, PitchForWidth(width, pixelFormat), dataPtr);
} }
size_t PixMapImpl::SizeForDimensions(uint16_t width, uint16_t height, GpPixelFormat_t pixelFormat) size_t PixMapImpl::SizeForDimensions(uint16_t width, uint16_t height, GpPixelFormat_t pixelFormat)
{ {
return AlignedSize() + PitchForWidth(width, pixelFormat) * height; return AlignedSize() + PitchForWidth(width, pixelFormat) * height;
} }
size_t PixMapImpl::AlignedSize() size_t PixMapImpl::AlignedSize()
{ {
const size_t szBase = sizeof(PixMapImpl) + PL_SYSTEM_MEMORY_ALIGNMENT - 1; const size_t szBase = sizeof(PixMapImpl) + PL_SYSTEM_MEMORY_ALIGNMENT - 1;
const size_t szAdjusted = szBase - szBase % PL_SYSTEM_MEMORY_ALIGNMENT; const size_t szAdjusted = szBase - szBase % PL_SYSTEM_MEMORY_ALIGNMENT;
return szAdjusted; return szAdjusted;
} }
size_t PixMapImpl::PitchForWidth(uint16_t width, GpPixelFormat_t pixelFormat) size_t PixMapImpl::PitchForWidth(uint16_t width, GpPixelFormat_t pixelFormat)
{ {
size_t rowByteCount = 0; size_t rowByteCount = 0;
switch (pixelFormat) switch (pixelFormat)
{ {
case GpPixelFormats::k8BitCustom: case GpPixelFormats::k8BitCustom:
case GpPixelFormats::k8BitStandard: case GpPixelFormats::k8BitStandard:
case GpPixelFormats::kBW1: case GpPixelFormats::kBW1:
rowByteCount = width; rowByteCount = width;
break;
case GpPixelFormats::kRGB555:
rowByteCount = width * 2;
break;
case GpPixelFormats::kRGB24:
rowByteCount = width * 3;
break;
case GpPixelFormats::kRGB32:
rowByteCount = width * 4;
break; break;
default: case GpPixelFormats::kRGB555:
assert(false); rowByteCount = width * 2;
return 0; break;
} case GpPixelFormats::kRGB24:
const size_t szBase = rowByteCount + PL_SYSTEM_MEMORY_ALIGNMENT - 1; rowByteCount = width * 3;
const size_t szAdjusted = szBase - szBase % PL_SYSTEM_MEMORY_ALIGNMENT; break;
case GpPixelFormats::kRGB32:
return szAdjusted; rowByteCount = width * 4;
} break;
} default:
assert(false);
return 0;
}
const size_t szBase = rowByteCount + PL_SYSTEM_MEMORY_ALIGNMENT - 1;
const size_t szAdjusted = szBase - szBase % PL_SYSTEM_MEMORY_ALIGNMENT;
return szAdjusted;
}
}
void PixMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, void *dataPtr) void PixMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, void *dataPtr)
{ {
BitMap::Init(rect, pixelFormat, pitch, dataPtr); BitMap::Init(rect, pixelFormat, pitch, dataPtr);
} }

View File

@@ -1,77 +1,77 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
namespace PortabilityLayer namespace PortabilityLayer
{ {
struct Vec2i struct Vec2i
{ {
int32_t m_x; int32_t m_x;
int32_t m_y; int32_t m_y;
Vec2i(); Vec2i();
Vec2i(const Vec2i &other); Vec2i(const Vec2i &other);
Vec2i(int32_t x, int32_t y); Vec2i(int32_t x, int32_t y);
Vec2i operator+(const Vec2i &other) const; Vec2i operator+(const Vec2i &other) const;
Vec2i operator-(const Vec2i &other) const; Vec2i operator-(const Vec2i &other) const;
Vec2i &operator+=(const Vec2i &other); Vec2i &operator+=(const Vec2i &other);
Vec2i &operator-=(const Vec2i &other); Vec2i &operator-=(const Vec2i &other);
bool operator==(const Vec2i &other) const; bool operator==(const Vec2i &other) const;
bool operator!=(const Vec2i &other) const; bool operator!=(const Vec2i &other) const;
}; };
inline Vec2i::Vec2i() inline Vec2i::Vec2i()
: m_x(0) : m_x(0)
, m_y(0) , m_y(0)
{ {
} }
inline Vec2i::Vec2i(const Vec2i &other) inline Vec2i::Vec2i(const Vec2i &other)
: m_x(other.m_x) : m_x(other.m_x)
, m_y(other.m_y) , m_y(other.m_y)
{ {
} }
inline Vec2i::Vec2i(int32_t x, int32_t y) inline Vec2i::Vec2i(int32_t x, int32_t y)
: m_x(x) : m_x(x)
, m_y(y) , m_y(y)
{ {
} }
inline Vec2i Vec2i::operator+(const Vec2i &other) const inline Vec2i Vec2i::operator+(const Vec2i &other) const
{ {
return Vec2i(m_x + other.m_x, m_y + other.m_y); return Vec2i(m_x + other.m_x, m_y + other.m_y);
} }
inline Vec2i Vec2i::operator-(const Vec2i &other) const inline Vec2i Vec2i::operator-(const Vec2i &other) const
{ {
return Vec2i(m_x - other.m_x, m_y - other.m_y); return Vec2i(m_x - other.m_x, m_y - other.m_y);
} }
inline Vec2i &Vec2i::operator+=(const Vec2i &other) inline Vec2i &Vec2i::operator+=(const Vec2i &other)
{ {
m_x += other.m_x; m_x += other.m_x;
m_y += other.m_y; m_y += other.m_y;
return *this; return *this;
} }
inline Vec2i &Vec2i::operator-=(const Vec2i &other) inline Vec2i &Vec2i::operator-=(const Vec2i &other)
{ {
m_x -= other.m_x; m_x -= other.m_x;
m_y -= other.m_y; m_y -= other.m_y;
return *this; return *this;
} }
inline bool Vec2i::operator==(const Vec2i &other) const inline bool Vec2i::operator==(const Vec2i &other) const
{ {
return m_x == other.m_x && m_y == other.m_y; return m_x == other.m_x && m_y == other.m_y;
} }
inline bool Vec2i::operator!=(const Vec2i &other) const inline bool Vec2i::operator!=(const Vec2i &other) const
{ {
return !((*this) == other); return !((*this) == other);
} }
} }