Bug 1102048 (Part 23, encoders) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth

This commit is contained in:
Glenn Randers-Pehrson 2015-04-06 19:19:00 -07:00
parent f4eed2926a
commit 5b06f4967b
5 changed files with 25 additions and 11 deletions

View File

@ -206,7 +206,7 @@ nsBMPEncoder::AddImageFrame(const uint8_t* aData,
}
} else if (aInputFormat == INPUT_FORMAT_RGBA) {
// simple RGBA, no conversion needed
for (int32_t y = 0; y < mBMPInfoHeader.height; y ++) {
for (int32_t y = 0; y < mBMPInfoHeader.height; y++) {
if (mBMPInfoHeader.bpp == 24) {
EncodeImageDataRow24(row);
} else {
@ -215,7 +215,7 @@ nsBMPEncoder::AddImageFrame(const uint8_t* aData,
}
} else if (aInputFormat == INPUT_FORMAT_RGB) {
// simple RGB, no conversion needed
for (int32_t y = 0; y < mBMPInfoHeader.height; y ++) {
for (int32_t y = 0; y < mBMPInfoHeader.height; y++) {
if (mBMPInfoHeader.bpp == 24) {
EncodeImageDataRow24(&aData[y * aStride]);
} else {
@ -700,7 +700,7 @@ nsBMPEncoder::EncodeImageDataRow24(const uint8_t* aData)
void
nsBMPEncoder::EncodeImageDataRow32(const uint8_t* aData)
{
for (int32_t x = 0; x < mBMPInfoHeader.width; x ++) {
for (int32_t x = 0; x < mBMPInfoHeader.width; x++) {
uint32_t pos = x * BytesPerPixel(mBMPInfoHeader.bpp);
SetPixel32(mImageBufferCurr, aData[pos], aData[pos + 1],
aData[pos + 2], aData[pos + 3]);
@ -708,7 +708,7 @@ nsBMPEncoder::EncodeImageDataRow32(const uint8_t* aData)
}
for (uint32_t x = 0; x < PaddingBytes(mBMPInfoHeader.bpp,
mBMPInfoHeader.width); x ++) {
mBMPInfoHeader.width); x++) {
*mImageBufferCurr++ = 0;
}
}

View File

@ -2,6 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_image_encoders_bmp_nsBMPEncoder_h
#define mozilla_image_encoders_bmp_nsBMPEncoder_h
#include "mozilla/Attributes.h"
#include "mozilla/ReentrantMonitor.h"
@ -91,3 +94,5 @@ protected:
nsCOMPtr<nsIEventTarget> mCallbackTarget;
uint32_t mNotifyThreshold;
};
#endif // mozilla_image_encoders_bmp_nsBMPEncoder_h

View File

@ -2,6 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_image_encoders_ico_nsICOEncoder_h
#define mozilla_image_encoders_ico_nsICOEncoder_h
#include "mozilla/Attributes.h"
#include "mozilla/ReentrantMonitor.h"
@ -96,3 +99,5 @@ protected:
nsCOMPtr<nsIEventTarget> mCallbackTarget;
uint32_t mNotifyThreshold;
};
#endif // mozilla_image_encoders_ico_nsICOEncoder_h

View File

@ -3,6 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_image_encoders_jpeg_nsJPEGEncoder_h
#define mozilla_image_encoders_jpeg_nsJPEGEncoder_h
#include "imgIEncoder.h"
#include "mozilla/ReentrantMonitor.h"
@ -77,3 +80,5 @@ protected:
// that only one thread dispatches a callback for each call to AsyncWait.
ReentrantMonitor mReentrantMonitor;
};
#endif // mozilla_image_encoders_jpeg_nsJPEGEncoder_h

View File

@ -36,8 +36,7 @@ nsPNGEncoder::nsPNGEncoder() : mPNG(nullptr), mPNGinfo(nullptr),
mCallbackTarget(nullptr), mNotifyThreshold(0),
mReentrantMonitor(
"nsPNGEncoder.mReentrantMonitor")
{
}
{ }
nsPNGEncoder::~nsPNGEncoder()
{
@ -291,7 +290,7 @@ nsPNGEncoder::AddImageFrame(const uint8_t* aData,
// PNG requires RGBA with post-multiplied alpha, so we need to
// convert
uint8_t* row = new uint8_t[aWidth * 4];
for (uint32_t y = 0; y < aHeight; y ++) {
for (uint32_t y = 0; y < aHeight; y++) {
ConvertHostARGBRow(&aData[y * aStride], row, aWidth, useTransparency);
png_write_row(mPNG, row);
}
@ -300,7 +299,7 @@ nsPNGEncoder::AddImageFrame(const uint8_t* aData,
} else if (aInputFormat == INPUT_FORMAT_RGBA && !useTransparency) {
// RBGA, but we need to strip the alpha
uint8_t* row = new uint8_t[aWidth * 4];
for (uint32_t y = 0; y < aHeight; y ++) {
for (uint32_t y = 0; y < aHeight; y++) {
StripAlpha(&aData[y * aStride], row, aWidth);
png_write_row(mPNG, row);
}
@ -309,7 +308,7 @@ nsPNGEncoder::AddImageFrame(const uint8_t* aData,
} else if (aInputFormat == INPUT_FORMAT_RGB ||
aInputFormat == INPUT_FORMAT_RGBA) {
// simple RBG(A), no conversion needed
for (uint32_t y = 0; y < aHeight; y ++) {
for (uint32_t y = 0; y < aHeight; y++) {
png_write_row(mPNG, (uint8_t*)&aData[y * aStride]);
}
@ -655,7 +654,7 @@ nsPNGEncoder::ConvertHostARGBRow(const uint8_t* aSrc, uint8_t* aDest,
bool aUseTransparency)
{
uint32_t pixelStride = aUseTransparency ? 4 : 3;
for (uint32_t x = 0; x < aPixelWidth; x ++) {
for (uint32_t x = 0; x < aPixelWidth; x++) {
const uint32_t& pixelIn = ((const uint32_t*)(aSrc))[x];
uint8_t* pixelOut = &aDest[x * pixelStride];
@ -684,7 +683,7 @@ void
nsPNGEncoder::StripAlpha(const uint8_t* aSrc, uint8_t* aDest,
uint32_t aPixelWidth)
{
for (uint32_t x = 0; x < aPixelWidth; x ++) {
for (uint32_t x = 0; x < aPixelWidth; x++) {
const uint8_t* pixelIn = &aSrc[x * 4];
uint8_t* pixelOut = &aDest[x * 3];
pixelOut[0] = pixelIn[0];