diff --git a/build/vs2012/Lol.sln b/build/vs2012/Lol.sln index 74bfb17b..8800efaf 100644 --- a/build/vs2012/Lol.sln +++ b/build/vs2012/Lol.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deushax", "..\..\games\deushax\deushax.vcxproj", "{EF1A4E80-63FA-4EB0-B834-12B6C500F31C}" ProjectSection(ProjectDependencies) = postProject {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} @@ -172,12 +174,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sprite_sorter", "..\..\peop EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squad_shooter", "..\..\people\touky\squad_shooter\squad_shooter.vcxproj", "{DB344310-4938-4294-AEE2-18512454585D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pimp", "Pimp", "{2195FB18-53BF-48AF-96B6-9BD242924EA5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "The Pimp", "The Pimp", "{2195FB18-53BF-48AF-96B6-9BD242924EA5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pimp", "..\..\tools\pimp\pimp.vcxproj", "{FFF58874-D460-41E6-AD65-DBFEC6E47A94}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squad_shooter", "..\..\people\touky\private\squad_shooter\squad_shooter.vcxproj", "{DB344310-4938-4294-AEE2-18512454585D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ORBIS = Debug|ORBIS @@ -751,60 +751,60 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {928A359C-9C41-400A-8D2D-A054B33A79F5} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} - {9EA99B18-D352-47F6-BC04-A0B49CAA2772} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} - {0A1651FC-322B-4B04-82CB-28E9046D9383} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} - {E27FDF36-50C4-4ED2-8CF5-A20FED016910} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} - {B583BBFF-BE97-4F4E-BA1E-1F978A31EAB0} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} - {454DE15C-9063-4EB1-AD6C-77D7150F15DF} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} - {2F87CEAB-4818-443C-A5E3-6C34E7D967EC} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} - {33704AA4-F2B5-4138-A40D-E3E77F89ED46} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} - {8C77EAA8-1077-4EF7-AE53-97C6C60A3601} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} - {50509BA3-D27B-4FAC-9772-9EC76146F709} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} - {08C6A854-533D-4A1E-924E-C4A62281869F} = {928A359C-9C41-400A-8D2D-A054B33A79F5} - {9C66B179-0737-4BDA-AB42-2ADE478A9008} = {08C6A854-533D-4A1E-924E-C4A62281869F} {EF1A4E80-63FA-4EB0-B834-12B6C500F31C} = {08C6A854-533D-4A1E-924E-C4A62281869F} {17F0F184-4436-4D08-B8AA-16572EA238DB} = {2F87CEAB-4818-443C-A5E3-6C34E7D967EC} + {9C66B179-0737-4BDA-AB42-2ADE478A9008} = {08C6A854-533D-4A1E-924E-C4A62281869F} + {08C6A854-533D-4A1E-924E-C4A62281869F} = {928A359C-9C41-400A-8D2D-A054B33A79F5} + {2F87CEAB-4818-443C-A5E3-6C34E7D967EC} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} + {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {1AFD580B-98B8-4689-B661-38C41132C60E} {83D3B207-C601-4025-8F41-01DEDC354661} = {1AFD580B-98B8-4689-B661-38C41132C60E} {D84021CA-B233-4E0F-8A52-071B83BBCCC4} = {1AFD580B-98B8-4689-B661-38C41132C60E} - {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {1AFD580B-98B8-4689-B661-38C41132C60E} {B1E10086-A1DA-401A-834D-969C9DBB5CC1} = {E0491194-35E3-4513-9D31-608EA3165ECF} {80F81C11-8DA2-4990-91CB-9807783BA46E} = {E0491194-35E3-4513-9D31-608EA3165ECF} - {EE203B88-44CF-4859-9D42-7A1F43FECB52} = {E0491194-35E3-4513-9D31-608EA3165ECF} - {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E} = {E0491194-35E3-4513-9D31-608EA3165ECF} {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} = {E5C5E320-C077-4362-9A3F-3920C6447601} - {F7D4A671-612F-4FF4-883F-2097697694B7} = {E5C5E320-C077-4362-9A3F-3920C6447601} + {B92ABADC-45BE-4CC5-B724-9426053123A1} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} {7B083DA2-FE08-4F6D-BFDD-195D5C2783EB} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} {1C5B8702-290C-42DA-AA9E-671348F5B747} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} {6BF81B39-EDC2-4227-9992-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {BCEE0132-8E24-49BE-AFEB-96DAD14396BA} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {B0A53D75-CBB4-4FDF-93AC-2D12A79ADA0E} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {834852DB-EDB6-4FD0-BCF9-45CD01126962} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {6BF81B39-EDC2-4227-9982-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {B92ABADC-45BE-4CC5-B724-9426053123A1} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {572E5B9C-7E19-489C-BD8A-E8401CFBBC47} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} - {E05E23A5-67DE-42B5-98A3-E63CCE0CC0AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {33704AA4-F2B5-4138-A40D-E3E77F89ED46} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} {32F3F8CF-D22E-45E4-BEB8-AD909E8C5515} = {33704AA4-F2B5-4138-A40D-E3E77F89ED46} + {8C77EAA8-1077-4EF7-AE53-97C6C60A3601} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} {EE203B88-44CF-4859-9D42-7A5F40FECB52} = {8C77EAA8-1077-4EF7-AE53-97C6C60A3601} {B357514A-7881-422D-8358-161B689E7620} = {3D341D8A-E400-4B1D-BC05-B5C35487D9B5} - {2195FB18-53BF-48AF-96B6-9BD242924EA5} = {3D341D8A-E400-4B1D-BC05-B5C35487D9B5} {587FCCE9-1D8D-4398-B8B6-E8F4E9A92233} = {B357514A-7881-422D-8358-161B689E7620} + {9EA99B18-D352-47F6-BC04-A0B49CAA2772} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} {EE203B88-44CF-4859-9D42-7A5F43FECB52} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} - {25493FC8-75AC-4703-AD58-AB0C4A0FB79C} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} - {6BF81B39-EDC2-4127-9982-C2D8ABEA95AF} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} - {EE203B88-44CF-4829-9D42-7A5F43FECB52} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} - {7422B977-CA61-49BF-A586-F57B6FF9BD64} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} - {DB344310-4938-4294-AEE2-18512454585D} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} + {EE203B88-44CF-4859-9D42-7A1F43FECB52} = {E0491194-35E3-4513-9D31-608EA3165ECF} + {BCEE0132-8E24-49BE-AFEB-96DAD14396BA} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {0A1651FC-322B-4B04-82CB-28E9046D9383} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} {A69411B3-6DE8-404E-8E70-0D3375A7492A} = {0A1651FC-322B-4B04-82CB-28E9046D9383} - {5A77DCDD-2CBA-43E9-8B45-00C281443F77} = {0A1651FC-322B-4B04-82CB-28E9046D9383} + {928A359C-9C41-400A-8D2D-A054B33A79F5} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} + {E27FDF36-50C4-4ED2-8CF5-A20FED016910} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} {C2E01551-B636-4324-8461-71811DF6FBB5} = {E27FDF36-50C4-4ED2-8CF5-A20FED016910} + {B0A53D75-CBB4-4FDF-93AC-2D12A79ADA0E} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {5A77DCDD-2CBA-43E9-8B45-00C281443F77} = {0A1651FC-322B-4B04-82CB-28E9046D9383} + {834852DB-EDB6-4FD0-BCF9-45CD01126962} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {B583BBFF-BE97-4F4E-BA1E-1F978A31EAB0} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} {FAF82AD2-D9F4-4694-9A01-103BC5B771B4} = {B583BBFF-BE97-4F4E-BA1E-1F978A31EAB0} + {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E} = {E0491194-35E3-4513-9D31-608EA3165ECF} + {25493FC8-75AC-4703-AD58-AB0C4A0FB79C} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} + {6BF81B39-EDC2-4227-9982-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {6BF81B39-EDC2-4127-9982-C2D8ABEA95AF} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} + {AA376B9B-484B-4DC4-982F-6CFA645E441E} = {F7D4A671-612F-4FF4-883F-2097697694B7} + {F7D4A671-612F-4FF4-883F-2097697694B7} = {E5C5E320-C077-4362-9A3F-3920C6447601} + {572E5B9C-7E19-489C-BD8A-E8401CFBBC47} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {E05E23A5-67DE-42B5-98A3-E63CCE0CC0AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} {52493826-AC00-470B-A745-4F602529B3B0} = {B583BBFF-BE97-4F4E-BA1E-1F978A31EAB0} {9F291982-8C81-4105-BF39-16844648E55F} = {B583BBFF-BE97-4F4E-BA1E-1F978A31EAB0} {950EDCC1-DF6A-4A75-B083-DFE98E7DD34F} = {B583BBFF-BE97-4F4E-BA1E-1F978A31EAB0} - {AA376B9B-484B-4DC4-982F-6CFA645E441E} = {F7D4A671-612F-4FF4-883F-2097697694B7} + {50509BA3-D27B-4FAC-9772-9EC76146F709} = {1DFE1729-4F1B-47CA-9819-72431FE14E25} {5D994A3B-83BF-4FCB-9AC1-E7B642B46FEA} = {50509BA3-D27B-4FAC-9772-9EC76146F709} + {454DE15C-9063-4EB1-AD6C-77D7150F15DF} = {5F1AAF03-7202-4C07-B99F-EB397105B1B7} {C3E2D690-F2B4-4A11-B317-D5CB8EF9561A} = {454DE15C-9063-4EB1-AD6C-77D7150F15DF} + {EE203B88-44CF-4829-9D42-7A5F43FECB52} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} + {7422B977-CA61-49BF-A586-F57B6FF9BD64} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} + {DB344310-4938-4294-AEE2-18512454585D} = {9EA99B18-D352-47F6-BC04-A0B49CAA2772} + {2195FB18-53BF-48AF-96B6-9BD242924EA5} = {3D341D8A-E400-4B1D-BC05-B5C35487D9B5} {FFF58874-D460-41E6-AD65-DBFEC6E47A94} = {2195FB18-53BF-48AF-96B6-9BD242924EA5} EndGlobalSection EndGlobal diff --git a/src/image/filter/convolution.cpp b/src/image/filter/convolution.cpp index 2ef0b3ef..9acf6863 100644 --- a/src/image/filter/convolution.cpp +++ b/src/image/filter/convolution.cpp @@ -108,8 +108,8 @@ static Image NonSepConv(Image &src, Array2D const &kernel) ivec2 const ksize = kernel.GetSize(); Image dst(size); - pixel_t const *srcp = src.Lock(); - pixel_t *dstp = dst.Lock(); + Array2D const &srcp = src.Lock2D(); + Array2D &dstp = dst.Lock2D(); for (int y = 0; y < size.y; y++) { @@ -135,16 +135,16 @@ static Image NonSepConv(Image &src, Array2D const &kernel) else if (x2 >= size.x) x2 = WRAP_X ? x2 % size.x : size.x - 1; - pixel += f * srcp[y2 * size.x + x2]; + pixel += f * srcp[x2][y2]; } } - dstp[y * size.x + x] = lol::clamp(pixel, 0.0f, 1.0f); + dstp[x][y] = lol::clamp(pixel, 0.0f, 1.0f); } } - src.Unlock(srcp); - dst.Unlock(dstp); + src.Unlock2D(srcp); + dst.Unlock2D(dstp); return dst; } @@ -201,8 +201,8 @@ static Image SepConv(Image &src, Array const &hvec, ivec2 const ksize(hvec.Count(), vvec.Count()); Image dst(size); - pixel_t const *srcp = src.Lock(); - pixel_t *dstp = dst.Lock(); + Array2D const &srcp = src.Lock2D(); + Array2D &dstp = dst.Lock2D(); Array2D tmp(size); @@ -220,7 +220,7 @@ static Image SepConv(Image &src, Array const &hvec, else if (x2 >= size.x) x2 = WRAP_X ? x2 % size.x : size.x - 1; - pixel += hvec[dx] * srcp[y * size.x + x2]; + pixel += hvec[dx] * srcp[x2][y]; } tmp[x][y] = pixel; @@ -244,12 +244,12 @@ static Image SepConv(Image &src, Array const &hvec, pixel += vvec[j] * tmp[x][y2]; } - dstp[y * size.x + x] = lol::clamp(pixel, 0.0f, 1.0f); + dstp[x][y] = lol::clamp(pixel, 0.0f, 1.0f); } } - src.Unlock(srcp); - dst.Unlock(dstp); + src.Unlock2D(srcp); + dst.Unlock2D(dstp); return dst; } diff --git a/src/image/image-private.h b/src/image/image-private.h index 434848f4..52752076 100644 --- a/src/image/image-private.h +++ b/src/image/image-private.h @@ -19,6 +19,31 @@ 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; + + inline virtual ~PixelDataBase() {} +}; + +template +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; } + + Array2D::type> m_array2d; +}; + class ImageData { friend class Image; @@ -37,7 +62,7 @@ public: WrapMode m_wrap_x, m_wrap_y; /* A map of the various available bitplanes */ - Map m_pixels; + Map m_pixels; /* The last bitplane being accessed for writing */ PixelFormat m_format; }; diff --git a/src/image/image.cpp b/src/image/image.cpp index 300939ff..71a4f78e 100644 --- a/src/image/image.cpp +++ b/src/image/image.cpp @@ -109,9 +109,9 @@ Image::Image (Image const &other) if (fmt != PixelFormat::Unknown) { SetFormat(fmt); - void *psrc = other.m_data->m_pixels[(int)fmt]; - void *pdst = m_data->m_pixels[(int)fmt]; - memcpy(pdst, psrc, size.x * size.y * BytesPerPixel(fmt)); + memcpy(m_data->m_pixels[(int)fmt]->Data(), + other.m_data->m_pixels[(int)fmt]->Data(), + size.x * size.y * BytesPerPixel(fmt)); } } @@ -126,10 +126,8 @@ Image & Image::operator =(Image other) Image::~Image() { for (int k : m_data->m_pixels.Keys()) - { - delete[] (uint8_t *)m_data->m_pixels[k]; - m_data->m_pixels[k] = nullptr; - } + delete m_data->m_pixels[k]; + delete m_data; } @@ -161,11 +159,12 @@ void Image::SetSize(ivec2 size) if (m_data->m_size != size) { - /* FIXME: delete data or resize it */ - if (m_data->m_format != PixelFormat::Unknown) + for (int k : m_data->m_pixels.Keys()) { - m_data->m_pixels.Remove((int)m_data->m_format); + delete m_data->m_pixels[k]; + m_data->m_pixels[k] = nullptr; } + m_data->m_format = PixelFormat::Unknown; } @@ -194,17 +193,35 @@ template typename PixelType::type *Image::Lock() { SetFormat(T); - return (typename PixelType::type *)m_data->m_pixels[(int)T]; + return (typename PixelType::type *)m_data->m_pixels[(int)T]->Data(); } -/* Explicit specialisations for the above template */ -#define _T(T) template PixelType::type *Image::Lock() -_T(PixelFormat::Y_8); -_T(PixelFormat::RGB_8); -_T(PixelFormat::RGBA_8); -_T(PixelFormat::Y_F32); -_T(PixelFormat::RGB_F32); -_T(PixelFormat::RGBA_F32); +/* The Lock2D() method */ +template Array2D::type> &Image::Lock2D() +{ + SetFormat(T); + + return *(Array2D::type> *)m_data->m_pixels[(int)T]->Data2D(); +} + +template +void Image::Unlock2D(Array2D const &array) +{ + ASSERT(m_data->m_pixels.HasKey((int)m_data->m_format)); + ASSERT(array.Data() == m_data->m_pixels[(int)m_data->m_format]->Data()); +} + +/* Explicit specialisations for the above templates */ +#define _T(T) \ + template PixelType::type *Image::Lock(); \ + template Array2D::type> &Image::Lock2D(); \ + template void Image::Unlock2D(Array2D::type> const &array); +_T(PixelFormat::Y_8) +_T(PixelFormat::RGB_8) +_T(PixelFormat::RGBA_8) +_T(PixelFormat::Y_F32) +_T(PixelFormat::RGB_F32) +_T(PixelFormat::RGBA_F32) #undef _T /* Special case for the "any" format: return the last active buffer */ @@ -212,20 +229,13 @@ void *Image::Lock() { ASSERT(m_data->m_format != PixelFormat::Unknown); - return m_data->m_pixels[(int)m_data->m_format]; + return m_data->m_pixels[(int)m_data->m_format]->Data(); } void Image::Unlock(void const *pixels) { ASSERT(m_data->m_pixels.HasKey((int)m_data->m_format)); - - /* Ensure that the unlocked data is inside the buffer */ - uintptr_t start = (uintptr_t)m_data->m_pixels[(int)m_data->m_format]; - uintptr_t end = start + m_data->m_size.x * m_data->m_size.y - * BytesPerPixel(m_data->m_format); - - ASSERT(start <= (uintptr_t)pixels); - ASSERT((uintptr_t)pixels <= end); + ASSERT(pixels == m_data->m_pixels[(int)m_data->m_format]->Data()); } bool Image::RetrieveTiles(Array& tiles) const diff --git a/src/image/pixels.cpp b/src/image/pixels.cpp index cb1a01fd..ce62bab1 100644 --- a/src/image/pixels.cpp +++ b/src/image/pixels.cpp @@ -67,7 +67,25 @@ void Image::SetFormat(PixelFormat fmt) * obviously need it. */ if (m_data->m_pixels[(int)fmt] == nullptr) { - m_data->m_pixels[(int)fmt] = new uint8_t[count * BytesPerPixel(fmt)]; + PixelDataBase *data = nullptr; + switch (fmt) + { + case PixelFormat::Y_8: + data = new PixelData(size); break; + case PixelFormat::RGB_8: + data = new PixelData(size); break; + case PixelFormat::RGBA_8: + data = new PixelData(size); break; + case PixelFormat::Y_F32: + data = new PixelData(size); break; + case PixelFormat::RGB_F32: + data = new PixelData(size); break; + case PixelFormat::RGBA_F32: + data = new PixelData(size); break; + default: + ASSERT(false, "invalid pixel type %d", (int)fmt); + } + m_data->m_pixels[(int)fmt] = data; } /* If the requested format is already the current format, or if the @@ -78,24 +96,24 @@ void Image::SetFormat(PixelFormat fmt) /* Convert pixels */ if (old_fmt == PixelFormat::RGBA_8 && fmt == PixelFormat::RGBA_F32) { - u8vec4 *src = (u8vec4 *)m_data->m_pixels[(int)old_fmt]; - vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]; + 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]); } else if (old_fmt == PixelFormat::RGB_8 && fmt == PixelFormat::RGBA_F32) { - u8vec3 *src = (u8vec3 *)m_data->m_pixels[(int)old_fmt]; - vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]; + 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_F32 && fmt == PixelFormat::RGBA_8) { - vec4 *src = (vec4 *)m_data->m_pixels[(int)old_fmt]; - u8vec4 *dest = (u8vec4 *)m_data->m_pixels[(int)fmt]; + 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]); @@ -133,16 +151,16 @@ void Image::SetFormat(PixelFormat fmt) } else if (old_fmt == PixelFormat::Y_F32 && fmt == PixelFormat::RGBA_F32) { - float *src = (float *)m_data->m_pixels[(int)old_fmt]; - vec4 *dest = (vec4 *)m_data->m_pixels[(int)fmt]; + 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); } else if (old_fmt == PixelFormat::RGBA_F32 && fmt == PixelFormat::Y_F32) { - vec4 *src = (vec4 *)m_data->m_pixels[(int)old_fmt]; - float *dest = (float *)m_data->m_pixels[(int)fmt]; + vec4 *src = (vec4 *)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); diff --git a/src/lol/image/image.h b/src/lol/image/image.h index 17d69176..612e3ea1 100644 --- a/src/lol/image/image.h +++ b/src/lol/image/image.h @@ -94,6 +94,11 @@ public: void *Lock(); void Unlock(void const *pixels); + template + Array2D::type> &Lock2D(); + template + void Unlock2D(Array2D const &); + bool RetrieveTiles(Array& tiles) const; /* Image processing kernels */