Переглянути джерело

base: various Visual Studio compilation fixes.

undefined
Sam Hocevar 10 роки тому
джерело
коміт
32abfb18d1
6 змінених файлів з 107 додано та 9 видалено
  1. +2
    -3
      src/image/codec/gdiplus-image.cpp
  2. +4
    -0
      src/image/pixel.cpp
  3. +92
    -1
      src/lol/base/array.h
  4. +4
    -0
      src/lol/image/pixel.h
  5. +2
    -2
      src/lol/math/array2d.h
  6. +3
    -3
      src/lol/math/array3d.h

+ 2
- 3
src/image/codec/gdiplus-image.cpp Переглянути файл

@@ -124,9 +124,8 @@ bool GdiPlusImageCodec::Load(Image *image, char const *path)
image->SetSize(size);
u8vec4 *pdst = image->Lock<PixelFormat::RGBA_8>();
u8vec4 *psrc = static_cast<u8vec4 *>(bdata.Scan0);
for (int y = 0; y < size.y; y++)
for (int x = 0; x < size.x; x++)
*pdst++ = (*psrc++).bgra;
for (int n = 0; n < size.x * size.y; n++)
pdst[n] = psrc[n].bgra;
image->Unlock(pdst);

bitmap->UnlockBits(&bdata);


+ 4
- 0
src/image/pixel.cpp Переглянути файл

@@ -68,8 +68,10 @@ void Image::SetFormat(PixelFormat fmt)
if (m_data->m_pixels[(int)fmt] == nullptr)
{
PixelDataBase *data = nullptr;
#if __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#endif
switch (fmt)
{
case PixelFormat::Unknown:
@@ -87,7 +89,9 @@ void Image::SetFormat(PixelFormat fmt)
case PixelFormat::RGBA_F32:
data = new PixelData<PixelFormat::RGBA_F32>(size); break;
}
#if __GNUC__
#pragma GCC diagnostic pop
#endif
ASSERT(data, "invalid pixel type %d", (int)fmt);
m_data->m_pixels[(int)fmt] = data;
}


+ 92
- 1
src/lol/base/array.h Переглянути файл

@@ -29,6 +29,9 @@
namespace lol
{

/* Set this to 1 when Visual Studio finally understands the feature */
#define INHERIT_CONSTRUCTORS 0

#define INDEX_NONE -1

/*
@@ -52,7 +55,7 @@ public:
m_count(0),
m_reserved(0)
{
Reserve(list.size());
Reserve((int)list.size());
for (auto elem : list)
Push(elem);
}
@@ -548,8 +551,19 @@ template<typename T1, typename T2 = void, typename T3 = void,
class Array : public ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, T8>,
Array<T1, T2, T3, T4, T5, T6, T7, T8>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, T8>,
Array<T1, T2, T3, T4, T5, T6, T7, T8>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, T8>,
Array<T1, T2, T3, T4, T5, T6, T7, T8>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, T8>,
Array<T1, T2, T3, T4, T5, T6, T7, T8>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
@@ -590,8 +604,19 @@ class Array<T1, T2, T3, T4, T5, T6, T7, void>
: public ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, void>,
Array<T1, T2, T3, T4, T5, T6, T7>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, void>,
Array<T1, T2, T3, T4, T5, T6, T7>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, void>,
Array<T1, T2, T3, T4, T5, T6, T7>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, T7, void>,
Array<T1, T2, T3, T4, T5, T6, T7>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
@@ -630,8 +655,19 @@ class Array<T1, T2, T3, T4, T5, T6, void, void>
: public ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, void, void>,
Array<T1, T2, T3, T4, T5, T6>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, void, void>,
Array<T1, T2, T3, T4, T5, T6>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, void, void>,
Array<T1, T2, T3, T4, T5, T6>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, T6, void, void>,
Array<T1, T2, T3, T4, T5, T6>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
@@ -667,8 +703,19 @@ class Array<T1, T2, T3, T4, T5, void, void, void>
: public ArrayBase<ArrayElement<T1, T2, T3, T4, T5, void, void, void>,
Array<T1, T2, T3, T4, T5>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, T3, T4, T5, void, void, void>,
Array<T1, T2, T3, T4, T5>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, void, void, void>,
Array<T1, T2, T3, T4, T5>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, T3, T4, T5, void, void, void>,
Array<T1, T2, T3, T4, T5>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
@@ -702,8 +749,19 @@ class Array<T1, T2, T3, T4, void, void, void, void>
: public ArrayBase<ArrayElement<T1, T2, T3, T4, void, void, void, void>,
Array<T1, T2, T3, T4>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, T3, T4, void, void, void, void>,
Array<T1, T2, T3, T4>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, T3, T4, void, void, void, void>,
Array<T1, T2, T3, T4>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, T3, T4, void, void, void, void>,
Array<T1, T2, T3, T4>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4)
@@ -733,8 +791,19 @@ class Array<T1, T2, T3, void, void, void, void, void>
: public ArrayBase<ArrayElement<T1, T2, T3, void, void, void, void, void>,
Array<T1, T2, T3>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, T3, void, void, void, void, void>,
Array<T1, T2, T3>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, T3, void, void, void, void, void>,
Array<T1, T2, T3>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, T3, void, void, void, void, void>,
Array<T1, T2, T3>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3)
@@ -762,8 +831,19 @@ class Array<T1, T2, void, void, void, void, void, void>
: public ArrayBase<ArrayElement<T1, T2, void, void, void, void, void, void>,
Array<T1, T2>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<ArrayElement<T1, T2, void, void, void, void, void, void>,
Array<T1, T2>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<ArrayElement<T1, T2, void, void, void, void, void, void>,
Array<T1, T2>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<ArrayElement<T1, T2, void, void, void, void, void, void>,
Array<T1, T2>>::ArrayBase(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2)
@@ -789,8 +869,19 @@ class Array<T, void, void, void, void, void, void, void>
: public ArrayBase<T,
Array<T>>
{
#if INHERIT_CONSTRUCTORS
using ArrayBase<T,
Array<T>>::ArrayBase;
#else
public:
inline Array()
: ArrayBase<T,
Array<T>>::ArrayBase() {}

inline Array(std::initializer_list<Element> const &list)
: ArrayBase<T,
Array<T>>::ArrayBase(list) {}
#endif
};

} /* namespace lol */


+ 4
- 0
src/lol/image/pixel.h Переглянути файл

@@ -44,8 +44,10 @@ template<> struct PixelType<PixelFormat::RGBA_F32> { typedef vec4 type; };
/* Number of bytes used by each pixel format */
static inline uint8_t BytesPerPixel(PixelFormat format)
{
#if __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#endif
switch (format)
{
case PixelFormat::Unknown:
@@ -64,7 +66,9 @@ static inline uint8_t BytesPerPixel(PixelFormat format)
return 16;
}
return 0;
#if __GNUC__
#pragma GCC diagnostic pop
#endif
};

} /* namespace lol */


+ 2
- 2
src/lol/math/array2d.h Переглянути файл

@@ -46,8 +46,8 @@ public:

inline Array2D(std::initializer_list<
std::initializer_list<Element>> const &list)
: m_size(list.size() ? (*list.begin()).size() : 0,
list.size())
: m_size(list.size() ? (int)(*list.begin()).size() : 0,
(int)list.size())
{
Super::Reserve(m_size.x * m_size.y);
for (auto l : list)


+ 3
- 3
src/lol/math/array3d.h Переглянути файл

@@ -48,9 +48,9 @@ public:
std::initializer_list<
std::initializer_list<Element>>> const &list)
: m_size(list.size() && (*list.begin()).size() ?
(*(*list.begin()).begin()).size() : 0,
list.size() ? (*list.begin()).size() : 0,
list.size())
(int)(*(*list.begin()).begin()).size() : 0,
list.size() ? (int)(*list.begin()).size() : 0,
(int)list.size())
{
Super::Reserve(m_size.x * m_size.y * m_size.z);
for (auto ll : list)


Завантаження…
Відмінити
Зберегти