X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fapisurface.cpp;h=7bf3c8fe5f20c8531d27a4a4feacbfc320c5ad6c;hb=e9426dd61586757d23d7dddc85b3076f477e7f07;hp=32ebff2853452144fc5ade36ce5373a20e33afe3;hpb=3b9fc082c5d17d4325f17dcbb0d49d0c91ffea6c;p=apitrace diff --git a/gui/apisurface.cpp b/gui/apisurface.cpp index 32ebff2..7bf3c8f 100644 --- a/gui/apisurface.cpp +++ b/gui/apisurface.cpp @@ -17,55 +17,21 @@ void ApiSurface::setSize(const QSize &size) m_size = size; } -static inline int -rgba8_to_argb(quint8 r, quint8 g, quint8 b, quint8 a) +int ApiSurface::numChannels() const { - return (a << 24 | r << 16 | g << 8 | b); + return m_numChannels; } -static inline int -rgbaf2argb(float r, float g, float b, float a) +void ApiSurface::setNumChannels(int numChannels) { - quint8 rb = r * 255; - quint8 gb = g * 255; - quint8 bb = b * 255; - quint8 ab = a * 255; - - return (ab << 24 | rb << 16 | gb << 8 | bb); + m_numChannels = numChannels; } void ApiSurface::contentsFromBase64(const QByteArray &base64) { QByteArray dataArray = QByteArray::fromBase64(base64); - const quint8 *data = (const quint8*)dataArray.data(); - int width = m_size.width(); - int height = m_size.height(); - - if (width <= 0 || height <= 0) - return; - - int *pixelData = (int*)malloc(sizeof(int) * width * height); - - //XXX not sure if this will work when - // QSysInfo::ByteOrder == QSysInfo::BigEndian - - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; ++x) { - int pixel = rgba8_to_argb(data[(y * width + x) * 4 + 0], - data[(y * width + x) * 4 + 1], - data[(y * width + x) * 4 + 2], - data[(y * width + x) * 4 + 3]); - pixelData[y * width + x] = pixel; - } - } - - m_image = QImage((uchar*)pixelData, - width, height, - QImage::Format_ARGB32).mirrored(); + m_image.loadFromData(dataArray, "png"); m_thumb = m_image.scaled(64, 64, Qt::KeepAspectRatio); - //m_image.save("testoutput.png"); - - free(pixelData); } QImage ApiSurface::image() const @@ -78,39 +44,54 @@ QImage ApiSurface::thumb() const return m_thumb; } -ApiTexture::ApiTexture() - : ApiSurface(), - m_unit(0), - m_level(0) +int ApiSurface::depth() const +{ + return m_depth; +} + +void ApiSurface::setDepth(int depth) { + m_depth = depth; } -int ApiTexture::unit() const +QString ApiSurface::formatName() const { - return m_unit; + return m_formatName; } -void ApiTexture::setUnit(int un) +void ApiSurface::setFormatName(const QString &str) { - m_unit = un; + m_formatName = str; } -QString ApiTexture::target() const + +ApiTexture::ApiTexture() + : ApiSurface() { - return m_target; } -void ApiTexture::setTarget(const QString &str) +QString ApiTexture::label() const { - m_target = str; + return m_label; } -int ApiTexture::level() const +void ApiTexture::setLabel(const QString &str) { - return m_level; + m_label = str; } -void ApiTexture::setLevel(int l) +ApiFramebuffer::ApiFramebuffer() + : ApiSurface() { - m_level = l; } + +QString ApiFramebuffer::type() const +{ + return m_type; +} + +void ApiFramebuffer::setType(const QString &str) +{ + m_type = str; +} +