|
|
@@ -26,15 +26,321 @@ THE SOFTWARE.
|
|
|
-----------------------------------------------------------------------------
|
|
|
*/
|
|
|
|
|
|
-#include "CmPixelFormat.h"
|
|
|
+#include "CmPixelUtil.h"
|
|
|
#include "CmBitwise.h"
|
|
|
#include "CmColor.h"
|
|
|
-#include "CmImageResampler.h"
|
|
|
#include "CmException.h"
|
|
|
|
|
|
|
|
|
namespace CamelotEngine {
|
|
|
|
|
|
+ //-----------------------------------------------------------------------
|
|
|
+ /**
|
|
|
+ * Resamplers
|
|
|
+ */
|
|
|
+
|
|
|
+ // variable name hints:
|
|
|
+ // sx_48 = 16/48-bit fixed-point x-position in source
|
|
|
+ // stepx = difference between adjacent sx_48 values
|
|
|
+ // sx1 = lower-bound integer x-position in source
|
|
|
+ // sx2 = upper-bound integer x-position in source
|
|
|
+ // sxf = fractional weight beween sx1 and sx2
|
|
|
+ // x,y,z = location of output pixel in destination
|
|
|
+
|
|
|
+ // nearest-neighbor resampler, does not convert formats.
|
|
|
+ // templated on bytes-per-pixel to allow compiler optimizations, such
|
|
|
+ // as simplifying memcpy() and replacing multiplies with bitshifts
|
|
|
+ template<unsigned int elemsize> struct NearestResampler {
|
|
|
+ static void scale(const PixelData& src, const PixelData& dst) {
|
|
|
+ // assert(src.format == dst.format);
|
|
|
+
|
|
|
+ // srcdata stays at beginning, pdst is a moving pointer
|
|
|
+ UINT8* srcdata = (UINT8*)src.data;
|
|
|
+ UINT8* pdst = (UINT8*)dst.data;
|
|
|
+
|
|
|
+ // sx_48,sy_48,sz_48 represent current position in source
|
|
|
+ // using 16/48-bit fixed precision, incremented by steps
|
|
|
+ UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
|
|
|
+ UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
|
|
|
+ UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
|
|
|
+
|
|
|
+ // note: ((stepz>>1) - 1) is an extra half-step increment to adjust
|
|
|
+ // for the center of the destination pixel, not the top-left corner
|
|
|
+ UINT64 sz_48 = (stepz >> 1) - 1;
|
|
|
+ for (size_t z = dst.front; z < dst.back; z++, sz_48 += stepz) {
|
|
|
+ size_t srczoff = (size_t)(sz_48 >> 48) * src.slicePitch;
|
|
|
+
|
|
|
+ UINT64 sy_48 = (stepy >> 1) - 1;
|
|
|
+ for (size_t y = dst.top; y < dst.bottom; y++, sy_48 += stepy) {
|
|
|
+ size_t srcyoff = (size_t)(sy_48 >> 48) * src.rowPitch;
|
|
|
+
|
|
|
+ UINT64 sx_48 = (stepx >> 1) - 1;
|
|
|
+ for (size_t x = dst.left; x < dst.right; x++, sx_48 += stepx) {
|
|
|
+ UINT8* psrc = srcdata +
|
|
|
+ elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
|
|
|
+ memcpy(pdst, psrc, elemsize);
|
|
|
+ pdst += elemsize;
|
|
|
+ }
|
|
|
+ pdst += elemsize*dst.getRowSkip();
|
|
|
+ }
|
|
|
+ pdst += elemsize*dst.getSliceSkip();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ // default floating-point linear resampler, does format conversion
|
|
|
+ struct LinearResampler {
|
|
|
+ static void scale(const PixelData& src, const PixelData& dst) {
|
|
|
+ size_t srcelemsize = PixelUtil::getNumElemBytes(src.format);
|
|
|
+ size_t dstelemsize = PixelUtil::getNumElemBytes(dst.format);
|
|
|
+
|
|
|
+ // srcdata stays at beginning, pdst is a moving pointer
|
|
|
+ UINT8* srcdata = (UINT8*)src.data;
|
|
|
+ UINT8* pdst = (UINT8*)dst.data;
|
|
|
+
|
|
|
+ // sx_48,sy_48,sz_48 represent current position in source
|
|
|
+ // using 16/48-bit fixed precision, incremented by steps
|
|
|
+ UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
|
|
|
+ UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
|
|
|
+ UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
|
|
|
+
|
|
|
+ // temp is 16/16 bit fixed precision, used to adjust a source
|
|
|
+ // coordinate (x, y, or z) backwards by half a pixel so that the
|
|
|
+ // integer bits represent the first sample (eg, sx1) and the
|
|
|
+ // fractional bits are the blend weight of the second sample
|
|
|
+ unsigned int temp;
|
|
|
+
|
|
|
+ // note: ((stepz>>1) - 1) is an extra half-step increment to adjust
|
|
|
+ // for the center of the destination pixel, not the top-left corner
|
|
|
+ UINT64 sz_48 = (stepz >> 1) - 1;
|
|
|
+ for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
|
|
|
+ temp = static_cast<unsigned int>(sz_48 >> 32);
|
|
|
+ temp = (temp > 0x8000)? temp - 0x8000 : 0;
|
|
|
+ size_t sz1 = temp >> 16; // src z, sample #1
|
|
|
+ size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
|
|
|
+ float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
|
|
|
+
|
|
|
+ UINT64 sy_48 = (stepy >> 1) - 1;
|
|
|
+ for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
|
|
|
+ temp = static_cast<unsigned int>(sy_48 >> 32);
|
|
|
+ temp = (temp > 0x8000)? temp - 0x8000 : 0;
|
|
|
+ size_t sy1 = temp >> 16; // src y #1
|
|
|
+ size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
|
|
|
+ float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
|
|
|
+
|
|
|
+ UINT64 sx_48 = (stepx >> 1) - 1;
|
|
|
+ for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
|
|
|
+ temp = static_cast<unsigned int>(sx_48 >> 32);
|
|
|
+ temp = (temp > 0x8000)? temp - 0x8000 : 0;
|
|
|
+ size_t sx1 = temp >> 16; // src x #1
|
|
|
+ size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
|
|
|
+ float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
|
|
|
+
|
|
|
+ Color x1y1z1, x2y1z1, x1y2z1, x2y2z1;
|
|
|
+ Color x1y1z2, x2y1z2, x1y2z2, x2y2z2;
|
|
|
+
|
|
|
+#define UNPACK(dst,x,y,z) PixelUtil::unpackColour(&dst, src.format, \
|
|
|
+ srcdata + srcelemsize*((x)+(y)*src.rowPitch+(z)*src.slicePitch))
|
|
|
+
|
|
|
+ UNPACK(x1y1z1,sx1,sy1,sz1); UNPACK(x2y1z1,sx2,sy1,sz1);
|
|
|
+ UNPACK(x1y2z1,sx1,sy2,sz1); UNPACK(x2y2z1,sx2,sy2,sz1);
|
|
|
+ UNPACK(x1y1z2,sx1,sy1,sz2); UNPACK(x2y1z2,sx2,sy1,sz2);
|
|
|
+ UNPACK(x1y2z2,sx1,sy2,sz2); UNPACK(x2y2z2,sx2,sy2,sz2);
|
|
|
+#undef UNPACK
|
|
|
+
|
|
|
+ Color accum =
|
|
|
+ x1y1z1 * ((1.0f - sxf)*(1.0f - syf)*(1.0f - szf)) +
|
|
|
+ x2y1z1 * ( sxf *(1.0f - syf)*(1.0f - szf)) +
|
|
|
+ x1y2z1 * ((1.0f - sxf)* syf *(1.0f - szf)) +
|
|
|
+ x2y2z1 * ( sxf * syf *(1.0f - szf)) +
|
|
|
+ x1y1z2 * ((1.0f - sxf)*(1.0f - syf)* szf ) +
|
|
|
+ x2y1z2 * ( sxf *(1.0f - syf)* szf ) +
|
|
|
+ x1y2z2 * ((1.0f - sxf)* syf * szf ) +
|
|
|
+ x2y2z2 * ( sxf * syf * szf );
|
|
|
+
|
|
|
+ PixelUtil::packColour(accum, dst.format, pdst);
|
|
|
+
|
|
|
+ pdst += dstelemsize;
|
|
|
+ }
|
|
|
+ pdst += dstelemsize*dst.getRowSkip();
|
|
|
+ }
|
|
|
+ pdst += dstelemsize*dst.getSliceSkip();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ // float32 linear resampler, converts FLOAT32_RGB/FLOAT32_RGBA only.
|
|
|
+ // avoids overhead of pixel unpack/repack function calls
|
|
|
+ struct LinearResampler_Float32 {
|
|
|
+ static void scale(const PixelData& src, const PixelData& dst) {
|
|
|
+ size_t srcchannels = PixelUtil::getNumElemBytes(src.format) / sizeof(float);
|
|
|
+ size_t dstchannels = PixelUtil::getNumElemBytes(dst.format) / sizeof(float);
|
|
|
+ // assert(srcchannels == 3 || srcchannels == 4);
|
|
|
+ // assert(dstchannels == 3 || dstchannels == 4);
|
|
|
+
|
|
|
+ // srcdata stays at beginning, pdst is a moving pointer
|
|
|
+ float* srcdata = (float*)src.data;
|
|
|
+ float* pdst = (float*)dst.data;
|
|
|
+
|
|
|
+ // sx_48,sy_48,sz_48 represent current position in source
|
|
|
+ // using 16/48-bit fixed precision, incremented by steps
|
|
|
+ UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
|
|
|
+ UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
|
|
|
+ UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
|
|
|
+
|
|
|
+ // temp is 16/16 bit fixed precision, used to adjust a source
|
|
|
+ // coordinate (x, y, or z) backwards by half a pixel so that the
|
|
|
+ // integer bits represent the first sample (eg, sx1) and the
|
|
|
+ // fractional bits are the blend weight of the second sample
|
|
|
+ unsigned int temp;
|
|
|
+
|
|
|
+ // note: ((stepz>>1) - 1) is an extra half-step increment to adjust
|
|
|
+ // for the center of the destination pixel, not the top-left corner
|
|
|
+ UINT64 sz_48 = (stepz >> 1) - 1;
|
|
|
+ for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
|
|
|
+ temp = static_cast<unsigned int>(sz_48 >> 32);
|
|
|
+ temp = (temp > 0x8000)? temp - 0x8000 : 0;
|
|
|
+ size_t sz1 = temp >> 16; // src z, sample #1
|
|
|
+ size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
|
|
|
+ float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
|
|
|
+
|
|
|
+ UINT64 sy_48 = (stepy >> 1) - 1;
|
|
|
+ for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
|
|
|
+ temp = static_cast<unsigned int>(sy_48 >> 32);
|
|
|
+ temp = (temp > 0x8000)? temp - 0x8000 : 0;
|
|
|
+ size_t sy1 = temp >> 16; // src y #1
|
|
|
+ size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
|
|
|
+ float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
|
|
|
+
|
|
|
+ UINT64 sx_48 = (stepx >> 1) - 1;
|
|
|
+ for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
|
|
|
+ temp = static_cast<unsigned int>(sx_48 >> 32);
|
|
|
+ temp = (temp > 0x8000)? temp - 0x8000 : 0;
|
|
|
+ size_t sx1 = temp >> 16; // src x #1
|
|
|
+ size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
|
|
|
+ float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
|
|
|
+
|
|
|
+ // process R,G,B,A simultaneously for cache coherence?
|
|
|
+ float accum[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
|
|
+
|
|
|
+#define ACCUM3(x,y,z,factor) \
|
|
|
+ { float f = factor; \
|
|
|
+ size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
|
|
|
+ accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
|
|
|
+ accum[2]+=srcdata[off+2]*f; }
|
|
|
+
|
|
|
+#define ACCUM4(x,y,z,factor) \
|
|
|
+ { float f = factor; \
|
|
|
+ size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
|
|
|
+ accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
|
|
|
+ accum[2]+=srcdata[off+2]*f; accum[3]+=srcdata[off+3]*f; }
|
|
|
+
|
|
|
+ if (srcchannels == 3 || dstchannels == 3) {
|
|
|
+ // RGB, no alpha
|
|
|
+ ACCUM3(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
|
|
|
+ ACCUM3(sx2,sy1,sz1, sxf *(1.0f-syf)*(1.0f-szf));
|
|
|
+ ACCUM3(sx1,sy2,sz1,(1.0f-sxf)* syf *(1.0f-szf));
|
|
|
+ ACCUM3(sx2,sy2,sz1, sxf * syf *(1.0f-szf));
|
|
|
+ ACCUM3(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)* szf );
|
|
|
+ ACCUM3(sx2,sy1,sz2, sxf *(1.0f-syf)* szf );
|
|
|
+ ACCUM3(sx1,sy2,sz2,(1.0f-sxf)* syf * szf );
|
|
|
+ ACCUM3(sx2,sy2,sz2, sxf * syf * szf );
|
|
|
+ accum[3] = 1.0f;
|
|
|
+ } else {
|
|
|
+ // RGBA
|
|
|
+ ACCUM4(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
|
|
|
+ ACCUM4(sx2,sy1,sz1, sxf *(1.0f-syf)*(1.0f-szf));
|
|
|
+ ACCUM4(sx1,sy2,sz1,(1.0f-sxf)* syf *(1.0f-szf));
|
|
|
+ ACCUM4(sx2,sy2,sz1, sxf * syf *(1.0f-szf));
|
|
|
+ ACCUM4(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)* szf );
|
|
|
+ ACCUM4(sx2,sy1,sz2, sxf *(1.0f-syf)* szf );
|
|
|
+ ACCUM4(sx1,sy2,sz2,(1.0f-sxf)* syf * szf );
|
|
|
+ ACCUM4(sx2,sy2,sz2, sxf * syf * szf );
|
|
|
+ }
|
|
|
+
|
|
|
+ memcpy(pdst, accum, sizeof(float)*dstchannels);
|
|
|
+
|
|
|
+#undef ACCUM3
|
|
|
+#undef ACCUM4
|
|
|
+
|
|
|
+ pdst += dstchannels;
|
|
|
+ }
|
|
|
+ pdst += dstchannels*dst.getRowSkip();
|
|
|
+ }
|
|
|
+ pdst += dstchannels*dst.getSliceSkip();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // byte linear resampler, does not do any format conversions.
|
|
|
+ // only handles pixel formats that use 1 byte per color channel.
|
|
|
+ // 2D only; punts 3D pixelboxes to default LinearResampler (slow).
|
|
|
+ // templated on bytes-per-pixel to allow compiler optimizations, such
|
|
|
+ // as unrolling loops and replacing multiplies with bitshifts
|
|
|
+ template<unsigned int channels> struct LinearResampler_Byte {
|
|
|
+ static void scale(const PixelData& src, const PixelData& dst) {
|
|
|
+ // assert(src.format == dst.format);
|
|
|
+
|
|
|
+ // only optimized for 2D
|
|
|
+ if (src.getDepth() > 1 || dst.getDepth() > 1) {
|
|
|
+ LinearResampler::scale(src, dst);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // srcdata stays at beginning of slice, pdst is a moving pointer
|
|
|
+ UINT8* srcdata = (UINT8*)src.data;
|
|
|
+ UINT8* pdst = (UINT8*)dst.data;
|
|
|
+
|
|
|
+ // sx_48,sy_48 represent current position in source
|
|
|
+ // using 16/48-bit fixed precision, incremented by steps
|
|
|
+ UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
|
|
|
+ UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
|
|
|
+
|
|
|
+ // bottom 28 bits of temp are 16/12 bit fixed precision, used to
|
|
|
+ // adjust a source coordinate backwards by half a pixel so that the
|
|
|
+ // integer bits represent the first sample (eg, sx1) and the
|
|
|
+ // fractional bits are the blend weight of the second sample
|
|
|
+ unsigned int temp;
|
|
|
+
|
|
|
+ UINT64 sy_48 = (stepy >> 1) - 1;
|
|
|
+ for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
|
|
|
+ temp = static_cast<unsigned int>(sy_48 >> 36);
|
|
|
+ temp = (temp > 0x800)? temp - 0x800: 0;
|
|
|
+ unsigned int syf = temp & 0xFFF;
|
|
|
+ size_t sy1 = temp >> 12;
|
|
|
+ size_t sy2 = std::min(sy1+1, src.bottom-src.top-1);
|
|
|
+ size_t syoff1 = sy1 * src.rowPitch;
|
|
|
+ size_t syoff2 = sy2 * src.rowPitch;
|
|
|
+
|
|
|
+ UINT64 sx_48 = (stepx >> 1) - 1;
|
|
|
+ for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
|
|
|
+ temp = static_cast<unsigned int>(sx_48 >> 36);
|
|
|
+ temp = (temp > 0x800)? temp - 0x800 : 0;
|
|
|
+ unsigned int sxf = temp & 0xFFF;
|
|
|
+ size_t sx1 = temp >> 12;
|
|
|
+ size_t sx2 = std::min(sx1+1, src.right-src.left-1);
|
|
|
+
|
|
|
+ unsigned int sxfsyf = sxf*syf;
|
|
|
+ for (unsigned int k = 0; k < channels; k++) {
|
|
|
+ unsigned int accum =
|
|
|
+ srcdata[(sx1 + syoff1)*channels+k]*(0x1000000-(sxf<<12)-(syf<<12)+sxfsyf) +
|
|
|
+ srcdata[(sx2 + syoff1)*channels+k]*((sxf<<12)-sxfsyf) +
|
|
|
+ srcdata[(sx1 + syoff2)*channels+k]*((syf<<12)-sxfsyf) +
|
|
|
+ srcdata[(sx2 + syoff2)*channels+k]*sxfsyf;
|
|
|
+ // accum is computed using 8/24-bit fixed-point math
|
|
|
+ // (maximum is 0xFF000000; rounding will not cause overflow)
|
|
|
+ *pdst++ = static_cast<UINT8>((accum + 0x800000) >> 24);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pdst += channels*dst.getRowSkip();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
//-----------------------------------------------------------------------
|
|
|
/**
|
|
|
* A record that describes a pixel format in detail.
|
|
|
@@ -630,11 +936,11 @@ namespace CamelotEngine {
|
|
|
|
|
|
};
|
|
|
//-----------------------------------------------------------------------
|
|
|
- size_t PixelBox::getConsecutiveSize() const
|
|
|
+ size_t PixelData::getConsecutiveSize() const
|
|
|
{
|
|
|
return PixelUtil::getMemorySize(getWidth(), getHeight(), getDepth(), format);
|
|
|
}
|
|
|
- PixelBox PixelBox::getSubVolume(const Box &def) const
|
|
|
+ PixelData PixelData::getSubVolume(const Box &def) const
|
|
|
{
|
|
|
if(PixelUtil::isCompressed(format))
|
|
|
{
|
|
|
@@ -653,7 +959,7 @@ namespace CamelotEngine {
|
|
|
// Calculate new data origin
|
|
|
// Notice how we do not propagate left/top/front from the incoming box, since
|
|
|
// the returned pointer is already offset
|
|
|
- PixelBox rval(def.getWidth(), def.getHeight(), def.getDepth(), format,
|
|
|
+ PixelData rval(def.getWidth(), def.getHeight(), def.getDepth(), format,
|
|
|
((UINT8*)data) + ((def.left-left)*elemSize)
|
|
|
+ ((def.top-top)*rowPitch*elemSize)
|
|
|
+ ((def.front-front)*slicePitch*elemSize)
|
|
|
@@ -1235,13 +1541,13 @@ namespace CamelotEngine {
|
|
|
void PixelUtil::bulkPixelConversion(void *srcp, PixelFormat srcFormat,
|
|
|
void *destp, PixelFormat dstFormat, unsigned int count)
|
|
|
{
|
|
|
- PixelBox src(count, 1, 1, srcFormat, srcp),
|
|
|
+ PixelData src(count, 1, 1, srcFormat, srcp),
|
|
|
dst(count, 1, 1, dstFormat, destp);
|
|
|
|
|
|
bulkPixelConversion(src, dst);
|
|
|
}
|
|
|
//-----------------------------------------------------------------------
|
|
|
- void PixelUtil::bulkPixelConversion(const PixelBox &src, const PixelBox &dst)
|
|
|
+ void PixelUtil::bulkPixelConversion(const PixelData &src, const PixelData &dst)
|
|
|
{
|
|
|
assert(src.getWidth() == dst.getWidth() &&
|
|
|
src.getHeight() == dst.getHeight() &&
|
|
|
@@ -1309,7 +1615,7 @@ namespace CamelotEngine {
|
|
|
{
|
|
|
// Do the same conversion, with PF_A8R8G8B8, which has a lot of
|
|
|
// optimized conversions
|
|
|
- PixelBox tempdst = dst;
|
|
|
+ PixelData tempdst = dst;
|
|
|
tempdst.format = dst.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
|
|
|
bulkPixelConversion(src, tempdst);
|
|
|
return;
|
|
|
@@ -1320,7 +1626,7 @@ namespace CamelotEngine {
|
|
|
{
|
|
|
// Do the same conversion, with PF_A8R8G8B8, which has a lot of
|
|
|
// optimized conversions
|
|
|
- PixelBox tempsrc = src;
|
|
|
+ PixelData tempsrc = src;
|
|
|
tempsrc.format = src.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
|
|
|
bulkPixelConversion(tempsrc, dst);
|
|
|
return;
|
|
|
@@ -1363,12 +1669,12 @@ namespace CamelotEngine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void PixelUtil::scale(const PixelBox &src, const PixelBox &scaled, Filter filter)
|
|
|
+ void PixelUtil::scale(const PixelData &src, const PixelData &scaled, Filter filter)
|
|
|
{
|
|
|
assert(PixelUtil::isAccessible(src.format));
|
|
|
assert(PixelUtil::isAccessible(scaled.format));
|
|
|
|
|
|
- PixelBox temp;
|
|
|
+ PixelData temp;
|
|
|
switch (filter)
|
|
|
{
|
|
|
default:
|
|
|
@@ -1381,7 +1687,7 @@ namespace CamelotEngine {
|
|
|
else
|
|
|
{
|
|
|
// Allocate temporary buffer of destination size in source format
|
|
|
- temp = PixelBox(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
|
|
|
+ temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
|
|
|
temp.data = malloc(temp.getConsecutiveSize());
|
|
|
}
|
|
|
// super-optimized: no conversion
|
|
|
@@ -1425,7 +1731,7 @@ namespace CamelotEngine {
|
|
|
else
|
|
|
{
|
|
|
// Allocate temp buffer of destination size in source format
|
|
|
- temp = PixelBox(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
|
|
|
+ temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
|
|
|
temp.data = malloc(temp.getConsecutiveSize());
|
|
|
}
|
|
|
// super-optimized: byte-oriented math, no conversion
|
|
|
@@ -1463,7 +1769,7 @@ namespace CamelotEngine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Color PixelBox::getColourAt(size_t x, size_t y, size_t z)
|
|
|
+ Color PixelData::getColourAt(size_t x, size_t y, size_t z)
|
|
|
{
|
|
|
Color cv;
|
|
|
|
|
|
@@ -1474,7 +1780,7 @@ namespace CamelotEngine {
|
|
|
return cv;
|
|
|
}
|
|
|
|
|
|
- void PixelBox::setColourAt(Color const &cv, size_t x, size_t y, size_t z)
|
|
|
+ void PixelData::setColourAt(Color const &cv, size_t x, size_t y, size_t z)
|
|
|
{
|
|
|
unsigned char pixelSize = PixelUtil::getNumElemBytes(format);
|
|
|
size_t pixelOffset = pixelSize * (z * slicePitch + y * rowPitch + x);
|