Selaa lähdekoodia

base: minor variable renaming.

undefined
Sam Hocevar 10 vuotta sitten
vanhempi
commit
3835dc62e0
9 muutettua tiedostoa jossa 67 lisäystä ja 67 poistoa
  1. +3
    -3
      src/image/codec/oric-image.cpp
  2. +1
    -1
      src/image/dither/dbs.cpp
  3. +9
    -9
      src/image/image-private.h
  4. +7
    -7
      src/image/image.cpp
  5. +2
    -2
      src/image/kernel.cpp
  6. +38
    -38
      src/image/pixel.cpp
  7. +2
    -2
      src/image/resample.cpp
  8. +4
    -4
      src/lol/math/arraynd.h
  9. +1
    -1
      src/t/math/arraynd.cpp

+ 3
- 3
src/image/codec/oric-image.cpp Näytä tiedosto

@@ -137,7 +137,7 @@ bool OricImageCodec::Save(Image *image, char const *path)

File f;
f.Open(path, FileAccess::Write);
f.Write(result.Data(), result.Bytes());
f.Write(result.data(), result.bytes());
f.Close();

return true;
@@ -473,8 +473,8 @@ void OricImageCodec::WriteScreen(Image &image, array<uint8_t> &result)
src.SetSize(size + ivec2(1));
dst.SetSize(size + ivec2(1));

memset(src.Data(), 0, src.Bytes());
memset(dst.Data(), 0, dst.Bytes());
memset(src.data(), 0, src.bytes());
memset(dst.data(), 0, dst.bytes());

/* Import pixels into our custom format */
for (int y = 0; y < size.y; y++)


+ 1
- 1
src/image/dither/dbs.cpp Näytä tiedosto

@@ -49,7 +49,7 @@ Image Image::DitherDbs() const
* for two iterations, we stop considering changes to it. */
ivec2 const csize = (size + ivec2(CELL - 1)) / CELL;
array2d<int> changelist(csize);
memset(changelist.Data(), 0, changelist.Bytes());
memset(changelist.data(), 0, changelist.bytes());

Image dst = *this;
dst.SetFormat(PixelFormat::Y_F32);


+ 9
- 9
src/image/image-private.h Näytä tiedosto

@@ -21,10 +21,10 @@ namespace lol
class PixelDataBase
{
public:
virtual void *Data() = 0;
virtual void const *Data() const = 0;
virtual void *Data2D() = 0;
virtual void const *Data2D() const = 0;
virtual void *data() = 0;
virtual void const *data() const = 0;
virtual void *data2d() = 0;
virtual void const *data2d() const = 0;

inline virtual ~PixelDataBase() {}
};
@@ -35,10 +35,10 @@ class PixelData : public PixelDataBase
public:
inline PixelData(ivec2 size) { m_array2d.SetSize(size); }

virtual void *Data() { return m_array2d.Data(); }
virtual void const *Data() const { return m_array2d.Data(); }
virtual void *Data2D() { return &m_array2d; }
virtual void const *Data2D() const { return &m_array2d; }
virtual void *data() { return m_array2d.data(); }
virtual void const *data() const { return m_array2d.data(); }
virtual void *data2d() { return &m_array2d; }
virtual void const *data2d() const { return &m_array2d; }

array2d<typename PixelType<T>::type> m_array2d;
};
@@ -82,7 +82,7 @@ public:
/* Insert image codecs in a sorted list */ \
ImageCodec *codec = Register##name(); \
int i = 0, prio = codec->m_priority; \
for ( ; i < codeclist.Count(); ++i) \
for ( ; i < codeclist.count(); ++i) \
{ \
if (codeclist[i]->m_priority <= prio) \
break; \


+ 7
- 7
src/image/image.cpp Näytä tiedosto

@@ -105,8 +105,8 @@ Image::Image (Image const &other)
if (fmt != PixelFormat::Unknown)
{
SetFormat(fmt);
memcpy(m_data->m_pixels[(int)fmt]->Data(),
other.m_data->m_pixels[(int)fmt]->Data(),
memcpy(m_data->m_pixels[(int)fmt]->data(),
other.m_data->m_pixels[(int)fmt]->data(),
size.x * size.y * BytesPerPixel(fmt));
}
}
@@ -189,7 +189,7 @@ template<PixelFormat T> typename PixelType<T>::type *Image::Lock()
{
SetFormat(T);

return (typename PixelType<T>::type *)m_data->m_pixels[(int)T]->Data();
return (typename PixelType<T>::type *)m_data->m_pixels[(int)T]->data();
}

/* The Lock2D() method */
@@ -197,14 +197,14 @@ void *Image::Lock2DHelper(PixelFormat T)
{
SetFormat(T);

return m_data->m_pixels[(int)T]->Data2D();
return m_data->m_pixels[(int)T]->data2d();
}

template<typename T>
void Image::Unlock2D(array2d<T> const &array)
{
ASSERT(m_data->m_pixels.has_key((int)m_data->m_format));
ASSERT(array.Data() == m_data->m_pixels[(int)m_data->m_format]->Data());
ASSERT(array.data() == m_data->m_pixels[(int)m_data->m_format]->data());
}

/* Explicit specialisations for the above templates */
@@ -225,13 +225,13 @@ void *Image::Lock()
{
ASSERT(m_data->m_format != PixelFormat::Unknown);

return m_data->m_pixels[(int)m_data->m_format]->Data();
return m_data->m_pixels[(int)m_data->m_format]->data();
}

void Image::Unlock(void const *pixels)
{
ASSERT(m_data->m_pixels.has_key((int)m_data->m_format));
ASSERT(pixels == m_data->m_pixels[(int)m_data->m_format]->Data());
ASSERT(pixels == m_data->m_pixels[(int)m_data->m_format]->data());
}

bool Image::RetrieveTiles(array<ivec2, ivec2>& tiles) const


+ 2
- 2
src/image/kernel.cpp Näytä tiedosto

@@ -129,7 +129,7 @@ array2d<float> Image::BlueNoiseKernel(ivec2 size, ivec2 gsize)

/* Generate an array with about 10% random dots */
int const ndots = (size.x * size.y + 9) / 10;
memset(dots.Data(), 0, dots.Bytes());
memset(dots.data(), 0, dots.bytes());
for (int n = 0; n < ndots; )
{
ivec2 pos(lol::rand(size.x), lol::rand(size.y));
@@ -194,7 +194,7 @@ array2d<float> Image::NormalizeKernel(array2d<float> const &kernel)
tmp[y * size.x + x].y = y;
tmp[y * size.x + x].val = kernel[x][y];
}
std::qsort(tmp.Data(), size.x * size.y, sizeof(Dot), cmpdot);
std::qsort(tmp.data(), size.x * size.y, sizeof(Dot), cmpdot);

array2d<float> dst(size);



+ 38
- 38
src/image/pixel.cpp Näytä tiedosto

@@ -156,64 +156,64 @@ void Image::SetFormat(PixelFormat fmt)
/* Easy conversions: just add or remove channels */
if (old_fmt == PixelFormat::Y_8 && fmt == PixelFormat::RGB_8)
{
uint8_t *src = (uint8_t *)m_data->m_pixels[(int)old_fmt]->Data();
u8vec3 *dest = (u8vec3 *)m_data->m_pixels[(int)fmt]->Data();
uint8_t *src = (uint8_t *)m_data->m_pixels[(int)old_fmt]->data();
u8vec3 *dest = (u8vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8vec3(src[n]);
}
else if (old_fmt == PixelFormat::Y_8 && fmt == PixelFormat::RGBA_8)
{
uint8_t *src = (uint8_t *)m_data->m_pixels[(int)old_fmt]->Data();
u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]->Data();
uint8_t *src = (uint8_t *)m_data->m_pixels[(int)old_fmt]->data();
u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8vec4(u8vec3(src[n]), 255);
}
else if (old_fmt == PixelFormat::RGBA_8 && fmt == PixelFormat::RGB_8)
{
u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]->Data();
u8vec3 *dest = (u8vec3 *)m_data->m_pixels[(int)fmt]->Data();
u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]->data();
u8vec3 *dest = (u8vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = src[n].rgb;
}
else if (old_fmt == PixelFormat::RGB_8 && fmt == PixelFormat::RGBA_8)
{
u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]->Data();
u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]->Data();
u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]->data();
u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8vec4(src[n], 255);
}
else if (old_fmt == PixelFormat::RGBA_F32 && fmt == PixelFormat::RGB_F32)
{
vec4 *src = (vec4 *)m_data->m_pixels[(int)old_fmt]->Data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->Data();
vec4 *src = (vec4 *)m_data->m_pixels[(int)old_fmt]->data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = src[n].rgb;
}
else if (old_fmt == PixelFormat::RGB_F32 && fmt == PixelFormat::RGBA_F32)
{
vec3 *src = (vec3 *)m_data->m_pixels[(int)old_fmt]->Data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->Data();
vec3 *src = (vec3 *)m_data->m_pixels[(int)old_fmt]->data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = vec4(src[n], 1.f);
}
else if (old_fmt == PixelFormat::Y_F32 && fmt == PixelFormat::RGB_F32)
{
float *src = (float *)m_data->m_pixels[(int)old_fmt]->Data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->Data();
float *src = (float *)m_data->m_pixels[(int)old_fmt]->data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = vec3(src[n]);
}
else if (old_fmt == PixelFormat::Y_F32 && fmt == PixelFormat::RGBA_F32)
{
float *src = (float *)m_data->m_pixels[(int)old_fmt]->Data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->Data();
float *src = (float *)m_data->m_pixels[(int)old_fmt]->data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = vec4(vec3(src[n]), 1.0f);
@@ -221,56 +221,56 @@ void Image::SetFormat(PixelFormat fmt)
/* Lossless conversions: u8 to float */
else if (old_fmt == PixelFormat::Y_8 && fmt == PixelFormat::Y_F32)
{
float *src = (float *)m_data->m_pixels[(int)old_fmt]->Data();
float *dest = (float *)m_data->m_pixels[(int)fmt]->Data();
float *src = (float *)m_data->m_pixels[(int)old_fmt]->data();
float *dest = (float *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(src[n]);
}
else if (old_fmt == PixelFormat::Y_8 && fmt == PixelFormat::RGB_F32)
{
float *src = (float *)m_data->m_pixels[(int)old_fmt]->Data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->Data();
float *src = (float *)m_data->m_pixels[(int)old_fmt]->data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(u8vec3(src[n]));
}
else if (old_fmt == PixelFormat::RGB_8 && fmt == PixelFormat::RGB_F32)
{
u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]->Data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->Data();
u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]->data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(src[n]);
}
else if (old_fmt == PixelFormat::RGBA_8 && fmt == PixelFormat::RGB_F32)
{
u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]->Data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->Data();
u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]->data();
vec3 *dest = (vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(src[n].rgb);
}
else if (old_fmt == PixelFormat::Y_8 && fmt == PixelFormat::RGBA_F32)
{
float *src = (float *)m_data->m_pixels[(int)old_fmt]->Data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->Data();
float *src = (float *)m_data->m_pixels[(int)old_fmt]->data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(u8vec4(u8vec3(src[n]), 255));
}
else if (old_fmt == PixelFormat::RGB_8 && fmt == PixelFormat::RGBA_F32)
{
u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]->Data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->Data();
u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]->data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(u8vec4(src[n], 255));
}
else if (old_fmt == PixelFormat::RGBA_8 && fmt == PixelFormat::RGBA_F32)
{
u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]->Data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->Data();
u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]->data();
vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = u8tof32(src[n]);
@@ -278,8 +278,8 @@ void Image::SetFormat(PixelFormat fmt)
/* Other conversions */
else if (old_fmt == PixelFormat::RGB_F32 && fmt == PixelFormat::Y_F32)
{
vec3 *src = (vec3 *)m_data->m_pixels[(int)old_fmt]->Data();
float *dest = (float *)m_data->m_pixels[(int)fmt]->Data();
vec3 *src = (vec3 *)m_data->m_pixels[(int)old_fmt]->data();
float *dest = (float *)m_data->m_pixels[(int)fmt]->data();

vec3 const coeff(0.299f, 0.587f, 0.114f);

@@ -288,24 +288,24 @@ void Image::SetFormat(PixelFormat fmt)
}
else if (old_fmt == PixelFormat::Y_F32 && fmt == PixelFormat::Y_8)
{
float *src = (float *)m_data->m_pixels[(int)old_fmt]->Data();
uint8_t *dest = (uint8_t *)m_data->m_pixels[(int)fmt]->Data();
float *src = (float *)m_data->m_pixels[(int)old_fmt]->data();
uint8_t *dest = (uint8_t *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = f32tou8(src[n]);
}
else if (old_fmt == PixelFormat::RGB_F32 && fmt == PixelFormat::RGB_8)
{
vec3 *src = (vec3 *)m_data->m_pixels[(int)old_fmt]->Data();
u8vec3 *dest = (u8vec3 *)m_data->m_pixels[(int)fmt]->Data();
vec3 *src = (vec3 *)m_data->m_pixels[(int)old_fmt]->data();
u8vec3 *dest = (u8vec3 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = f32tou8(src[n]);
}
else if (old_fmt == PixelFormat::RGBA_F32 && fmt == PixelFormat::RGBA_8)
{
vec4 *src = (vec4 *)m_data->m_pixels[(int)old_fmt]->Data();
u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]->Data();
vec4 *src = (vec4 *)m_data->m_pixels[(int)old_fmt]->data();
u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]->data();

for (int n = 0; n < count; ++n)
dest[n] = f32tou8(src[n]);


+ 2
- 2
src/image/resample.cpp Näytä tiedosto

@@ -146,13 +146,13 @@ static Image ResizeBresenham(Image &image, ivec2 size)
array<vec4> aline, line;
aline.Resize(size.x);
line.Resize(size.x);
memset(line.Data(), 0, line.Bytes());
memset(line.data(), 0, line.bytes());

int remy = 0;

for (int y = 0, y0 = 0; y < size.y; y++)
{
memset(aline.Data(), 0, aline.Bytes());
memset(aline.data(), 0, aline.bytes());

for (int toty = 0; toty < oldsize.y; )
{


+ 4
- 4
src/lol/math/arraynd.h Näytä tiedosto

@@ -251,10 +251,10 @@ public:
}

public:
inline element_t *Data() { return super::Data(); }
inline element_t const *Data() const { return super::Data(); }
inline ptrdiff_t Count() const { return super::Count(); }
inline ptrdiff_t Bytes() const { return super::Bytes(); }
inline element_t *data() { return super::data(); }
inline element_t const *data() const { return super::data(); }
inline ptrdiff_t count() const { return super::count(); }
inline ptrdiff_t bytes() const { return super::bytes(); }

private:
inline void FixSizes(element_t e = element_t())


+ 1
- 1
src/t/math/arraynd.cpp Näytä tiedosto

@@ -98,7 +98,7 @@ lolunit_declare_fixture(ArrayNDTest)
size[i] = 5;

arraynd<NDIM, uint8_t> a(size);
memset(a.Data(), 0, a.Bytes());
memset(a.data(), 0, a.bytes());
lolunit_assert_equal(a[2][3][2][0][1][4][0][1], 0x00);

vec_t<int, NDIM> v = { 2, 3, 2, 0, 1, 4, 0, 1 };


Ladataan…
Peruuta
Tallenna