Fixed some coding standard issues

This commit is contained in:
Olivier Prat 2017-09-21 09:32:34 +02:00
parent 037550f176
commit 5ec9c5bb45
4 changed files with 40 additions and 42 deletions

View file

@ -508,14 +508,12 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
case gpu::R11G11B10:
texel.format = GL_RGB;
texel.type = GL_UNSIGNED_INT_10F_11F_11F_REV;
// the type should be float
texel.internalFormat = GL_R11F_G11F_B10F;
break;
case gpu::RGB9E5:
texel.format = GL_RGB;
texel.type = GL_UNSIGNED_INT_5_9_9_9_REV;
// the type should be float
texel.internalFormat = GL_RGB9_E5;
break;

View file

@ -686,17 +686,17 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
auto mipFormat = cubeTexture.getStoredMipFormat();
std::function<glm::vec3(uint32)> unpackFunc;
switch (mipFormat.getSemantic())
{
case gpu::R11G11B10:
unpackFunc = glm::unpackF2x11_1x10;
break;
case gpu::RGB9E5:
unpackFunc = glm::unpackF3x9_E1x5;
break;
default:
assert(false);
break;
switch (mipFormat.getSemantic()) {
case gpu::R11G11B10:
unpackFunc = glm::unpackF2x11_1x10;
break;
case gpu::RGB9E5:
unpackFunc = glm::unpackF3x9_E1x5;
break;
default:
assert(false);
break;
}
const uint sqOrder = order*order;
@ -732,7 +732,7 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
for(int face=0; face < gpu::Texture::NUM_CUBE_FACES; face++) {
PROFILE_RANGE(render_gpu, "ProcessFace");
auto data = (const uint32*)cubeTexture.accessStoredMipFace(0, face)->readData();
auto data = reinterpret_cast<const uint32*>( cubeTexture.accessStoredMipFace(0, face)->readData() );
if (data == nullptr) {
continue;
}
@ -813,7 +813,7 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
// index of texel in texture
// get color from texture
glm::vec3 color{ 0.f, 0.f, 0.f };
glm::vec3 color{ 0.0f, 0.0f, 0.0f };
for (int i = 0; i < stride; ++i) {
for (int j = 0; j < stride; ++j) {
int k = (int)(x + i - halfStride + (y + j - halfStride) * width);

View file

@ -67,6 +67,10 @@ glm::uvec2 rectifyToSparseSize(const glm::uvec2& size) {
namespace image {
enum {
QIMAGE_HDR_FORMAT = QImage::Format_RGB30
};
TextureUsage::TextureLoader TextureUsage::getTextureLoaderForType(Type type, const QVariantMap& options) {
switch (type) {
case ALBEDO_TEXTURE:
@ -206,7 +210,7 @@ void setCubeTexturesCompressionEnabled(bool enabled) {
}
static float denormalize(float value, const float minValue) {
return value < minValue ? 0.f : value;
return value < minValue ? 0.0f : value;
}
uint32 packR11G11B10F(const glm::vec3& color) {
@ -319,17 +323,18 @@ struct OutputHandler : public nvtt::OutputHandler {
_data = static_cast<gpu::Byte*>(malloc(size));
_current = _data;
}
virtual bool writeData(const void* data, int size) override {
assert(_current + size <= _data + _size);
memcpy(_current, data, size);
_current += size;
return true;
}
virtual void endImage() override {
if (_face >= 0) {
_texture->assignStoredMipFace(_miplevel, _face, _size, static_cast<const gpu::Byte*>(_data));
}
else {
} else {
_texture->assignStoredMip(_miplevel, _size, static_cast<const gpu::Byte*>(_data));
}
free(_data);
@ -433,11 +438,11 @@ void generateHDRMips(gpu::Texture* texture, const QImage& image, int face) {
data.resize(width*height);
dataIt = data.begin();
for (auto lineNb = 0; lineNb < height; lineNb++) {
const uint32* srcPixelIt = (const uint32*)image.constScanLine(lineNb);
const uint32* srcPixelIt = reinterpret_cast<const uint32*>( image.constScanLine(lineNb) );
const uint32* srcPixelEnd = srcPixelIt + width;
while (srcPixelIt < srcPixelEnd) {
*dataIt = glm::vec4(unpackFunc(*srcPixelIt), 1.f);
*dataIt = glm::vec4(unpackFunc(*srcPixelIt), 1.0f);
++srcPixelIt;
++dataIt;
}
@ -446,7 +451,7 @@ void generateHDRMips(gpu::Texture* texture, const QImage& image, int face) {
nvtt::OutputOptions outputOptions;
outputOptions.setOutputHeader(false);
std::auto_ptr<nvtt::OutputHandler> outputHandler;
std::unique_ptr<nvtt::OutputHandler> outputHandler;
MyErrorHandler errorHandler;
outputOptions.setErrorHandler(&errorHandler);
nvtt::Context context;
@ -1086,29 +1091,29 @@ QImage convertToHDRFormat(QImage srcImage, gpu::Element format) {
#endif
switch (format.getSemantic()) {
case gpu::R11G11B10:
packFunc = packR11G11B10F;
case gpu::R11G11B10:
packFunc = packR11G11B10F;
#ifdef DEBUG_COLOR_PACKING
unpackFunc = glm::unpackF2x11_1x10;
unpackFunc = glm::unpackF2x11_1x10;
#endif
break;
case gpu::RGB9E5:
packFunc = glm::packF3x9_E1x5;
break;
case gpu::RGB9E5:
packFunc = glm::packF3x9_E1x5;
#ifdef DEBUG_COLOR_PACKING
unpackFunc = glm::unpackF3x9_E1x5;
unpackFunc = glm::unpackF3x9_E1x5;
#endif
break;
default:
qCWarning(imagelogging) << "Unsupported HDR format";
Q_UNREACHABLE();
return srcImage;
break;
default:
qCWarning(imagelogging) << "Unsupported HDR format";
Q_UNREACHABLE();
return srcImage;
}
srcImage = srcImage.convertToFormat(QImage::Format_ARGB32);
for (auto y = 0; y < srcImage.height(); y++) {
const QRgb* srcLineIt = (const QRgb*) srcImage.constScanLine(y);
const QRgb* srcLineIt = reinterpret_cast<const QRgb*>( srcImage.constScanLine(y) );
const QRgb* srcLineEnd = srcLineIt + srcImage.width();
uint32* hdrLineIt = (uint32*) hdrImage.scanLine(y);
uint32* hdrLineIt = reinterpret_cast<uint32*>( hdrImage.scanLine(y) );
glm::vec3 color;
while (srcLineIt < srcLineEnd) {
@ -1116,7 +1121,7 @@ QImage convertToHDRFormat(QImage srcImage, gpu::Element format) {
color.g = qGreen(*srcLineIt);
color.b = qBlue(*srcLineIt);
// Normalize and apply gamma
color /= 255.f;
color /= 255.0f;
color.r = powf(color.r, 2.2f);
color.g = powf(color.g, 2.2f);
color.b = powf(color.b, 2.2f);

View file

@ -13,11 +13,11 @@
#define hifi_image_Image_h
#include <QVariant>
#include <QImage>
#include <gpu/Texture.h>
class QByteArray;
class QImage;
namespace image {
@ -74,11 +74,6 @@ void setNormalTexturesCompressionEnabled(bool enabled);
void setGrayscaleTexturesCompressionEnabled(bool enabled);
void setCubeTexturesCompressionEnabled(bool enabled);
enum
{
QIMAGE_HDR_FORMAT = QImage::Format_RGB30
};
gpu::TexturePointer processImage(const QByteArray& content, const std::string& url, int maxNumPixels, TextureUsage::Type textureType);
} // namespace image