Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/)
This CL is part II of IV (I broke down the 1280 files into 4 CLs).
Review URL: https://codereview.appspot.com/6474054
git-svn-id: http://skia.googlecode.com/svn/trunk@5263 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/images/SkFlipPixelRef.cpp b/src/images/SkFlipPixelRef.cpp
index 4e42d6c..f3f54e8 100644
--- a/src/images/SkFlipPixelRef.cpp
+++ b/src/images/SkFlipPixelRef.cpp
@@ -86,7 +86,7 @@
const char* srcP = static_cast<const char*>(srcAddr) + offset;
const size_t rb = dst.rowBytes();
const size_t bytes = rect.width() << shift;
-
+
int height = rect.height();
while (--height >= 0) {
memcpy(dstP, srcP, bytes);
@@ -116,10 +116,10 @@
if (shift < 0) {
return;
}
-
+
const SkIRect bounds = {0, 0, dst.width(), dst.height()};
SkRegion::Cliperator iter(clip, bounds);
-
+
while (!iter.done()) {
copyRect(dst, iter.rect(), srcAddr, shift);
iter.next();
diff --git a/src/images/SkImageDecoder_libbmp.cpp b/src/images/SkImageDecoder_libbmp.cpp
index d3bb871..2cbdcc3 100644
--- a/src/images/SkImageDecoder_libbmp.cpp
+++ b/src/images/SkImageDecoder_libbmp.cpp
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
-
+
#include "bmpdecoderhelper.h"
#include "SkImageDecoder.h"
#include "SkScaledBitmapSampler.h"
@@ -18,7 +18,7 @@
class SkBMPImageDecoder : public SkImageDecoder {
public:
SkBMPImageDecoder() {}
-
+
virtual Format getFormat() const {
return kBMP_Format;
}
@@ -33,10 +33,10 @@
static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) {
static const char kBmpMagic[] = { 'B', 'M' };
-
+
size_t len = stream->getLength();
char buffer[sizeof(kBmpMagic)];
-
+
if (len > sizeof(kBmpMagic) &&
stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) &&
!memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) {
@@ -61,7 +61,7 @@
if (fJustBounds) {
return NULL;
}
-
+
fRGB.setCount(width * height * 3); // 3 == r, g, b
return fRGB.begin();
}
@@ -81,11 +81,11 @@
size_t length = stream->getLength();
SkAutoMalloc storage(length);
-
+
if (stream->read(storage.get(), length) != length) {
return false;
}
-
+
const bool justBounds = SkImageDecoder::kDecodeBounds_Mode == mode;
SkBmpDecoderCallback callback(justBounds);
@@ -98,11 +98,11 @@
return false;
}
}
-
+
// we don't need this anymore, so free it now (before we try to allocate
// the bitmap's pixels) rather than waiting for its destructor
storage.free();
-
+
int width = callback.width();
int height = callback.height();
SkBitmap::Config config = this->getPrefConfig(k32Bit_SrcDepth, false);
@@ -124,9 +124,9 @@
if (!this->allocPixelRef(bm, NULL)) {
return false;
}
-
+
SkAutoLockPixels alp(*bm);
-
+
if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, getDitherImage())) {
return false;
}
@@ -134,7 +134,7 @@
const int srcRowBytes = width * 3;
const int dstHeight = sampler.scaledHeight();
const uint8_t* srcRow = callback.rgb();
-
+
srcRow += sampler.srcY0() * srcRowBytes;
for (int y = 0; y < dstHeight; y++) {
sampler.next(srcRow);
diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp
index cd4ee22..3008130 100644
--- a/src/images/SkImageDecoder_libgif.cpp
+++ b/src/images/SkImageDecoder_libgif.cpp
@@ -21,7 +21,7 @@
virtual Format getFormat() const {
return kGIF_Format;
}
-
+
protected:
virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode);
};
@@ -48,7 +48,7 @@
fCurrY = *fStartYPtr++;
fDeltaY = *fDeltaYPtr++;
}
-
+
int currY() const {
SkASSERT(fStartYPtr);
SkASSERT(fDeltaYPtr);
@@ -77,7 +77,7 @@
}
fCurrY = y;
}
-
+
private:
const int fHeight;
int fCurrY;
@@ -167,22 +167,22 @@
GifRecordType recType;
GifByteType *extData;
int transpIndex = -1; // -1 means we don't have it (yet)
-
+
do {
if (DGifGetRecordType(gif, &recType) == GIF_ERROR) {
return error_return(gif, *bm, "DGifGetRecordType");
}
-
+
switch (recType) {
case IMAGE_DESC_RECORD_TYPE: {
if (DGifGetImageDesc(gif) == GIF_ERROR) {
return error_return(gif, *bm, "IMAGE_DESC_RECORD_TYPE");
}
-
+
if (gif->ImageCount < 1) { // sanity check
return error_return(gif, *bm, "ImageCount < 1");
}
-
+
width = gif->SWidth;
height = gif->SHeight;
if (width <= 0 || height <= 0 ||
@@ -190,21 +190,21 @@
width, height)) {
return error_return(gif, *bm, "chooseFromOneChoice");
}
-
+
bm->setConfig(SkBitmap::kIndex8_Config, width, height);
if (SkImageDecoder::kDecodeBounds_Mode == mode)
return true;
SavedImage* image = &gif->SavedImages[gif->ImageCount-1];
const GifImageDesc& desc = image->ImageDesc;
-
+
// check for valid descriptor
if ( (desc.Top | desc.Left) < 0 ||
desc.Left + desc.Width > width ||
desc.Top + desc.Height > height) {
return error_return(gif, *bm, "TopLeft");
}
-
+
// now we decode the colortable
int colorCount = 0;
{
@@ -218,7 +218,7 @@
SkPMColor* colorPtr = ctable->lockColors();
for (int index = 0; index < colorCount; index++)
colorPtr[index] = SkPackARGB32(0xFF,
- cmap->Colors[index].Red,
+ cmap->Colors[index].Red,
cmap->Colors[index].Green,
cmap->Colors[index].Blue);
@@ -234,7 +234,7 @@
return error_return(gif, *bm, "allocPixelRef");
}
}
-
+
SkAutoLockPixels alp(*bm);
// time to decode the scanlines
@@ -268,7 +268,7 @@
// bump our starting address
scanline += desc.Top * rowBytes + desc.Left;
}
-
+
// now decode each scanline
if (gif->Image.Interlace)
{
@@ -294,7 +294,7 @@
}
goto DONE;
} break;
-
+
case EXTENSION_RECORD_TYPE:
if (DGifGetExtension(gif, &temp_save.Function,
&extData) == GIF_ERROR) {
@@ -313,11 +313,11 @@
temp_save.Function = 0;
}
break;
-
+
case TERMINATE_RECORD_TYPE:
break;
-
- default: /* Should be trapped by DGifGetRecordType */
+
+ default: /* Should be trapped by DGifGetRecordType */
break;
}
} while (recType != TERMINATE_RECORD_TYPE);
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index 30611cb..5167fe1 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -15,7 +15,7 @@
class SkICOImageDecoder : public SkImageDecoder {
public:
SkICOImageDecoder();
-
+
virtual Format getFormat() const {
return kICO_Format;
}
@@ -46,23 +46,23 @@
}
//helpers - my function pointer will call one of these, depending on the bitCount, each time through the inner loop
-static void editPixelBit1(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit1(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
-static void editPixelBit4(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit4(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
-static void editPixelBit8(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit8(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
-static void editPixelBit24(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit24(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
-static void editPixelBit32(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit32(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
-
-
+
+
static int calculateRowBytesFor8888(int w, int bitCount)
{
// Default rowBytes is w << 2 for kARGB_8888
@@ -84,7 +84,7 @@
if (stream->read((void*)buf, length) != length) {
return false;
}
-
+
//these should always be the same - should i use for error checking? - what about files that have some
//incorrect values, but still decode properly?
int reserved = read2Bytes(buf, 0); // 0
@@ -92,11 +92,11 @@
if (reserved != 0 || type != 1)
return false;
int count = read2Bytes(buf, 4);
-
+
//need to at least have enough space to hold the initial table of info
if (length < (size_t)(6 + count*16))
return false;
-
+
int choice;
Chooser* chooser = this->getChooser();
//FIXME:if no chooser, consider providing the largest color image
@@ -120,7 +120,7 @@
case 1:
case 4:
// In reality, at least for the moment, these will be decoded into kARGB_8888 bitmaps.
- // However, this will be used to distinguish between the lower quality 1bpp and 4 bpp
+ // However, this will be used to distinguish between the lower quality 1bpp and 4 bpp
// images and the higher quality images.
c = SkBitmap::kIndex8_Config;
break;
@@ -137,11 +137,11 @@
}
choice = chooser->choose();
}
-
+
//you never know what the chooser is going to supply
- if (choice >= count || choice < 0)
+ if (choice >= count || choice < 0)
return false;
-
+
//skip ahead to the correct header
//commented out lines are not used, but if i switch to other read method, need to know how many to skip
//otherwise, they could be used for error checking
@@ -160,9 +160,9 @@
//int height = read4Bytes(buf, offset+8); //should == 2*h
//int planesToo = read2Bytes(buf, offset+12); //should == 1 (does it?)
int bitCount = read2Bytes(buf, offset+14);
-
- void (*placePixel)(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+
+ void (*placePixel)(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors) = NULL;
switch (bitCount)
{
@@ -190,7 +190,7 @@
SkDEBUGF(("Decoding %ibpp is unimplemented\n", bitCount));
return false;
}
-
+
//these should all be zero, but perhaps are not - need to check
//int compression = read4Bytes(buf, offset+16); //0
//int imageSize = read4Bytes(buf, offset+20); //0 - sometimes has a value
@@ -198,13 +198,13 @@
//int yPixels = read4Bytes(buf, offset+28); //0
//int colorsUsed = read4Bytes(buf, offset+32) //0 - might have an actual value though
//int colorsImportant = read4Bytes(buf, offset+36); //0
-
+
int begin = offset + 40;
//this array represents the colortable
//if i allow other types of bitmaps, it may actually be used as a part of the bitmap
SkPMColor* colors = NULL;
int blue, green, red;
- if (colorCount)
+ if (colorCount)
{
colors = new SkPMColor[colorCount];
for (int j = 0; j < colorCount; j++)
@@ -221,11 +221,11 @@
int mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | test) & 0x1); //either 0xFFFFFFFF or 0
int lineBitWidth = (bitWidth & 0xFFFFFFE0) + (0x20 & mask);
int lineWidth = lineBitWidth/bitCount;
-
+
int xorOffset = begin + colorCount*4; //beginning of the color bitmap
//other read method means we will just be here already
int andOffset = xorOffset + ((lineWidth*h*bitCount) >> 3);
-
+
/*int */test = w & 0x1F; //the low 5 bits - we are rounding up to the next 32 (2^5)
/*int */mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | test) & 0x1); //either 0xFFFFFFFF or 0
int andLineWidth = (w & 0xFFFFFFE0) + (0x20 & mask);
@@ -236,7 +236,7 @@
//however, with small images with large colortables, maybe it's better to still do argb_8888
bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor8888(w, bitCount));
-
+
if (SkImageDecoder::kDecodeBounds_Mode == mode) {
delete[] colors;
return true;
@@ -247,7 +247,7 @@
delete[] colors;
return false;
}
-
+
SkAutoLockPixels alp(*bm);
for (int y = 0; y < h; y++)
@@ -255,7 +255,7 @@
for (int x = 0; x < w; x++)
{
//U32* address = bm->getAddr32(x, y);
-
+
//check the alpha bit first, but pass it along to the function to figure out how to deal with it
int andPixelNo = andLineWidth*(h-y-1)+x;
//only need to get a new alphaByte when x %8 == 0
@@ -264,7 +264,7 @@
int alphaByte = readByte(buf, andOffset + (andPixelNo >> 3));
int shift = 7 - (andPixelNo & 0x7);
int m = 1 << shift;
-
+
int pixelNo = lineWidth*(h-y-1)+x;
placePixel(pixelNo, buf, xorOffset, x, y, w, bm, alphaByte, m, shift, colors);
@@ -279,8 +279,8 @@
} //onDecode
//function to place the pixel, determined by the bitCount
-static void editPixelBit1(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit1(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
{
// note that this should be the same as/similar to the AND bitmap
@@ -288,15 +288,15 @@
int byte = readByte(buf, xorOffset + (pixelNo >> 3));
int colorBit;
int alphaBit;
- // Read all of the bits in this byte.
+ // Read all of the bits in this byte.
int i = x + 8;
- // Pin to the width so we do not write outside the bounds of
+ // Pin to the width so we do not write outside the bounds of
// our color table.
i = i > w ? w : i;
// While loop to check all 8 bits individually.
while (x < i)
{
-
+
colorBit = (byte & m) >> shift;
alphaBit = (alphaByte & m) >> shift;
*address = (alphaBit-1)&(colors[colorBit]);
@@ -308,8 +308,8 @@
}
x--;
}
-static void editPixelBit4(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit4(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
{
SkPMColor* address = bm->getAddr32(x, y);
@@ -328,18 +328,18 @@
*address = (alphaBit-1)&(colors[pixel]);
}
-static void editPixelBit8(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit8(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
{
SkPMColor* address = bm->getAddr32(x, y);
int pixel = readByte(buf, xorOffset + pixelNo);
int alphaBit = (alphaByte & m) >> shift;
*address = (alphaBit-1)&(colors[pixel]);
-}
+}
-static void editPixelBit24(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit24(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
{
SkPMColor* address = bm->getAddr32(x, y);
@@ -349,11 +349,11 @@
int alphaBit = (alphaByte & m) >> shift;
//alphaBit == 1 => alpha = 0
int alpha = (alphaBit-1) & 0xFF;
- *address = SkPreMultiplyARGB(alpha, red, green, blue);
+ *address = SkPreMultiplyARGB(alpha, red, green, blue);
}
-static void editPixelBit32(const int pixelNo, const unsigned char* buf,
- const int xorOffset, int& x, int y, const int w,
+static void editPixelBit32(const int pixelNo, const unsigned char* buf,
+ const int xorOffset, int& x, int y, const int w,
SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
{
SkPMColor* address = bm->getAddr32(x, y);
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 8989d35..6bae965 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -147,7 +147,7 @@
// method moves the "scanline" pointer in its processing
static void convert_CMYK_to_RGB(uint8_t* scanline, unsigned int width) {
// At this point we've received CMYK pixels from libjpeg. We
- // perform a crude conversion to RGB (based on the formulae
+ // perform a crude conversion to RGB (based on the formulae
// from easyrgb.com):
// CMYK -> CMY
// C = ( C * (1 - K) + K ) // for each CMY component
@@ -294,9 +294,9 @@
a significant performance boost.
*/
if (sampleSize == 1 &&
- ((config == SkBitmap::kARGB_8888_Config &&
+ ((config == SkBitmap::kARGB_8888_Config &&
cinfo.out_color_space == JCS_RGBA_8888) ||
- (config == SkBitmap::kRGB_565_Config &&
+ (config == SkBitmap::kRGB_565_Config &&
cinfo.out_color_space == JCS_RGB_565)))
{
bm->setConfig(config, cinfo.output_width, cinfo.output_height);
@@ -310,7 +310,7 @@
SkAutoLockPixels alp(*bm);
JSAMPLE* rowptr = (JSAMPLE*)bm->getPixels();
INT32 const bpr = bm->rowBytes();
-
+
while (cinfo.output_scanline < cinfo.output_height) {
int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1);
// if row_count == 0, then we didn't get a scanline, so abort.
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 8fe3423..d48bce5 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -27,7 +27,7 @@
virtual Format getFormat() const {
return kPNG_Format;
}
-
+
protected:
virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode);
};
@@ -85,7 +85,7 @@
static bool substituteTranspColor(SkBitmap* bm, SkPMColor match) {
SkASSERT(bm->config() == SkBitmap::kARGB_8888_Config);
-
+
bool reallyHasAlpha = false;
for (int y = bm->height() - 1; y >= 0; --y) {
@@ -195,18 +195,18 @@
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
png_set_expand_gray_1_2_4_to_8(png_ptr);
}
-
+
/* Make a grayscale image into RGB. */
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
png_set_gray_to_rgb(png_ptr);
}
-
+
SkBitmap::Config config;
bool hasAlpha = false;
bool doDither = this->getDitherImage();
SkPMColor theTranspColor = 0; // 0 tells us not to try to match
-
+
// check for sBIT chunk data, in case we should disable dithering because
// our data is not truely 8bits per component
if (doDither) {
@@ -226,7 +226,7 @@
doDither = false;
}
}
-
+
if (color_type == PNG_COLOR_TYPE_PALETTE) {
bool paletteHasAlpha = hasTransparencyInPalette(png_ptr, info_ptr);
config = this->getPrefConfig(kIndex_SrcDepth, paletteHasAlpha);
@@ -237,11 +237,11 @@
} else {
png_color_16p transpColor = NULL;
int numTransp = 0;
-
+
png_get_tRNS(png_ptr, info_ptr, NULL, &numTransp, &transpColor);
-
+
bool valid = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS);
-
+
if (valid && numTransp == 1 && transpColor != NULL) {
/* Compute our transparent color, which we'll match against later.
We don't really handle 16bit components properly here, since we
@@ -304,7 +304,7 @@
if (!this->chooseFromOneChoice(config, origWidth, origHeight)) {
return false;
}
-
+
const int sampleSize = this->getSampleSize();
SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize);
@@ -313,7 +313,7 @@
if (SkImageDecoder::kDecodeBounds_Mode == mode) {
return true;
}
-
+
// from here down we are concerned with colortables and pixels
// we track if we actually see a non-opaque pixels, since sometimes a PNG sets its colortype
@@ -329,9 +329,9 @@
int num_trans;
png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
-
+
/* BUGGY IMAGE WORKAROUND
-
+
We hit some images (e.g. fruit_.png) who contain bytes that are == colortable_count
which is a problem since we use the byte as an index. To work around this we grow
the colortable by 1 (if its < 256) and duplicate the last color into that slot.
@@ -347,7 +347,7 @@
} else {
num_trans = 0;
colorTable->setFlags(colorTable->getFlags() | SkColorTable::kColorsAreOpaque_Flag);
- }
+ }
// check for bad images that might make us crash
if (num_trans > num_palette) {
num_trans = num_palette;
@@ -374,7 +374,7 @@
}
colorTable->unlockColors(true);
}
-
+
SkAutoUnref aur(colorTable);
if (!this->allocPixelRef(decodedBitmap,
@@ -382,7 +382,7 @@
colorTable : NULL)) {
return false;
}
-
+
SkAutoLockPixels alp(*decodedBitmap);
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
@@ -401,7 +401,7 @@
* png_read_image(). To see how to handle interlacing passes,
* see the png_read_row() method below:
*/
- const int number_passes = interlace_type != PNG_INTERLACE_NONE ?
+ const int number_passes = interlace_type != PNG_INTERLACE_NONE ?
png_set_interlace_handling(png_ptr) : 1;
/* Optional call to gamma correct and add the background to the palette
@@ -420,7 +420,7 @@
} else {
SkScaledBitmapSampler::SrcConfig sc;
int srcBytesPerPixel = 4;
-
+
if (colorTable != NULL) {
sc = SkScaledBitmapSampler::kIndex;
srcBytesPerPixel = 1;
@@ -508,7 +508,7 @@
static void transform_scanline_565(const char* SK_RESTRICT src, int width,
char* SK_RESTRICT dst) {
- const uint16_t* SK_RESTRICT srcP = (const uint16_t*)src;
+ const uint16_t* SK_RESTRICT srcP = (const uint16_t*)src;
for (int i = 0; i < width; i++) {
unsigned c = *srcP++;
*dst++ = SkPacked16ToR32(c);
@@ -519,7 +519,7 @@
static void transform_scanline_888(const char* SK_RESTRICT src, int width,
char* SK_RESTRICT dst) {
- const SkPMColor* SK_RESTRICT srcP = (const SkPMColor*)src;
+ const SkPMColor* SK_RESTRICT srcP = (const SkPMColor*)src;
for (int i = 0; i < width; i++) {
SkPMColor c = *srcP++;
*dst++ = SkGetPackedR32(c);
@@ -530,7 +530,7 @@
static void transform_scanline_444(const char* SK_RESTRICT src, int width,
char* SK_RESTRICT dst) {
- const SkPMColor16* SK_RESTRICT srcP = (const SkPMColor16*)src;
+ const SkPMColor16* SK_RESTRICT srcP = (const SkPMColor16*)src;
for (int i = 0; i < width; i++) {
SkPMColor16 c = *srcP++;
*dst++ = SkPacked4444ToR32(c);
@@ -542,7 +542,7 @@
static void transform_scanline_8888(const char* SK_RESTRICT src, int width,
char* SK_RESTRICT dst) {
const SkPMColor* SK_RESTRICT srcP = (const SkPMColor*)src;
- const SkUnPreMultiply::Scale* SK_RESTRICT table =
+ const SkUnPreMultiply::Scale* SK_RESTRICT table =
SkUnPreMultiply::GetScaleTable();
for (int i = 0; i < width; i++) {
@@ -568,7 +568,7 @@
static void transform_scanline_4444(const char* SK_RESTRICT src, int width,
char* SK_RESTRICT dst) {
const SkPMColor16* SK_RESTRICT srcP = (const SkPMColor16*)src;
- const SkUnPreMultiply::Scale* SK_RESTRICT table =
+ const SkUnPreMultiply::Scale* SK_RESTRICT table =
SkUnPreMultiply::GetScaleTable();
for (int i = 0; i < width; i++) {
@@ -603,7 +603,7 @@
if (SkBitmap::kIndex8_Config == config) {
hasAlpha = false; // we store false in the table entries for kIndex8
}
-
+
static const struct {
SkBitmap::Config fConfig;
bool fHasAlpha;
@@ -644,7 +644,7 @@
/* Pack palette[] with the corresponding colors, and if hasAlpha is true, also
pack trans[] and return the number of trans[] entries written. If hasAlpha
is false, the return value will always be 0.
-
+
Note: this routine takes care of unpremultiplying the RGB values when we
have alpha in the colortable, since png doesn't support premul colors
*/
@@ -672,7 +672,7 @@
}
num_trans -= 1;
}
-
+
const SkUnPreMultiply::Scale* SK_RESTRICT table =
SkUnPreMultiply::GetScaleTable();
@@ -684,11 +684,11 @@
palette[i].red = SkUnPreMultiply::ApplyScale(s, SkGetPackedR32(c));
palette[i].green = SkUnPreMultiply::ApplyScale(s,SkGetPackedG32(c));
palette[i].blue = SkUnPreMultiply::ApplyScale(s, SkGetPackedB32(c));
- }
+ }
// now fall out of this if-block to use common code for the trailing
// opaque entries
}
-
+
// these (remaining) entries are opaque
for (i = num_trans; i < ctCount; i++) {
SkPMColor c = *colors++;
@@ -743,7 +743,7 @@
default:
return false;
}
-
+
if (hasAlpha) {
// don't specify alpha if we're a palette, even if our ctable has alpha
if (!(colorType & PNG_COLOR_MASK_PALETTE)) {
@@ -752,7 +752,7 @@
} else {
sig_bit.alpha = 0;
}
-
+
SkAutoLockPixels alp(bitmap);
// readyToDraw checks for pixels (and colortable if that is required)
if (!bitmap.readyToDraw()) {
diff --git a/src/images/SkImageDecoder_wbmp.cpp b/src/images/SkImageDecoder_wbmp.cpp
index fedeedb..175a444 100644
--- a/src/images/SkImageDecoder_wbmp.cpp
+++ b/src/images/SkImageDecoder_wbmp.cpp
@@ -20,7 +20,7 @@
virtual Format getFormat() const {
return kWBMP_Format;
}
-
+
protected:
virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode);
};
@@ -40,7 +40,7 @@
}
n = (n << 7) | (data & 0x7F);
} while (data & 0x80);
-
+
*value = n;
return true;
}
@@ -48,11 +48,11 @@
struct wbmp_head {
int fWidth;
int fHeight;
-
+
bool init(SkStream* stream)
{
uint8_t data;
-
+
if (!read_byte(stream, &data) || data != 0) { // unknown type
return false;
}
@@ -68,11 +68,11 @@
return fWidth != 0 && fHeight != 0;
}
};
-
+
static void expand_bits_to_bytes(uint8_t dst[], const uint8_t src[], int bits)
{
int bytes = bits >> 3;
-
+
for (int i = 0; i < bytes; i++) {
unsigned mask = *src++;
dst[0] = (mask >> 7) & 1;
@@ -85,14 +85,14 @@
dst[7] = (mask >> 0) & 1;
dst += 8;
}
-
+
bits &= 7;
if (bits > 0) {
unsigned mask = *src;
do {
*dst++ = (mask >> 7) & 1;;
mask <<= 1;
- } while (--bits != 0);
+ } while (--bits != 0);
}
}
@@ -100,21 +100,21 @@
Mode mode)
{
wbmp_head head;
-
+
if (!head.init(stream)) {
return false;
}
-
+
int width = head.fWidth;
int height = head.fHeight;
-
+
// assign these directly, in case we return kDimensions_Result
decodedBitmap->setConfig(SkBitmap::kIndex8_Config, width, height);
decodedBitmap->setIsOpaque(true);
-
+
if (SkImageDecoder::kDecodeBounds_Mode == mode)
return true;
-
+
const SkPMColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
SkColorTable* ct = SkNEW_ARGS(SkColorTable, (colors, 2));
SkAutoUnref aur(ct);
diff --git a/src/images/SkImageRefPool.cpp b/src/images/SkImageRefPool.cpp
index c24dba0..b8bbfd2 100644
--- a/src/images/SkImageRefPool.cpp
+++ b/src/images/SkImageRefPool.cpp
@@ -56,7 +56,7 @@
void SkImageRefPool::setRAMUsed(size_t limit) {
SkImageRef* ref = fTail;
-
+
while (NULL != ref && fRAMUsed > limit) {
// only purge it if its pixels are unlocked
if (!ref->isLocked() && ref->fBitmap.getPixels()) {
@@ -71,7 +71,7 @@
ref->fBitmap.bytesPerPixel(),
(int)size, (int)fRAMUsed);
#endif
-
+
// remember the bitmap config (don't call reset),
// just clear the pixel memory
ref->fBitmap.setPixels(NULL);
@@ -86,44 +86,44 @@
void SkImageRefPool::addToHead(SkImageRef* ref) {
ref->fNext = fHead;
ref->fPrev = NULL;
-
+
if (fHead) {
SkASSERT(NULL == fHead->fPrev);
fHead->fPrev = ref;
}
fHead = ref;
-
+
if (NULL == fTail) {
fTail = ref;
}
fCount += 1;
SkASSERT(computeCount() == fCount);
-
+
fRAMUsed += ref->ramUsed();
}
void SkImageRefPool::addToTail(SkImageRef* ref) {
ref->fNext = NULL;
ref->fPrev = fTail;
-
+
if (fTail) {
SkASSERT(NULL == fTail->fNext);
fTail->fNext = ref;
}
fTail = ref;
-
+
if (NULL == fHead) {
fHead = ref;
}
fCount += 1;
SkASSERT(computeCount() == fCount);
-
+
fRAMUsed += ref->ramUsed();
}
void SkImageRefPool::detach(SkImageRef* ref) {
SkASSERT(fCount > 0);
-
+
if (fHead == ref) {
fHead = ref->fNext;
}
@@ -136,12 +136,12 @@
if (ref->fNext) {
ref->fNext->fPrev = ref->fPrev;
}
-
+
ref->fNext = ref->fPrev = NULL;
-
+
fCount -= 1;
SkASSERT(computeCount() == fCount);
-
+
SkASSERT(fRAMUsed >= ref->ramUsed());
fRAMUsed -= ref->ramUsed();
}
@@ -149,23 +149,23 @@
int SkImageRefPool::computeCount() const {
SkImageRef* ref = fHead;
int count = 0;
-
+
while (ref != NULL) {
count += 1;
ref = ref->fNext;
}
-
+
#ifdef SK_DEBUG
ref = fTail;
int count2 = 0;
-
+
while (ref != NULL) {
count2 += 1;
ref = ref->fPrev;
}
SkASSERT(count2 == count);
#endif
-
+
return count;
}
@@ -177,15 +177,15 @@
#if defined(SK_DEBUG) || defined(DUMP_IMAGEREF_LIFECYCLE)
SkDebugf("ImagePool dump: bugdet: %d used: %d count: %d\n",
(int)fRAMBudget, (int)fRAMUsed, fCount);
-
+
SkImageRef* ref = fHead;
-
+
while (ref != NULL) {
SkDebugf(" [%3d %3d %d] ram=%d data=%d locked=%d %s\n", ref->fBitmap.width(),
ref->fBitmap.height(), ref->fBitmap.config(),
ref->ramUsed(), (int)ref->fStream->getLength(),
ref->isLocked(), ref->getURI());
-
+
ref = ref->fNext;
}
#endif
diff --git a/src/images/SkImageRefPool.h b/src/images/SkImageRefPool.h
index d29b8db..08633ee 100644
--- a/src/images/SkImageRefPool.h
+++ b/src/images/SkImageRefPool.h
@@ -17,30 +17,30 @@
public:
SkImageRefPool();
~SkImageRefPool();
-
+
size_t getRAMBudget() const { return fRAMBudget; }
void setRAMBudget(size_t);
-
+
size_t getRAMUsed() const { return fRAMUsed; }
void setRAMUsed(size_t limit);
-
+
void addToHead(SkImageRef*);
void addToTail(SkImageRef*);
void detach(SkImageRef*);
void dump() const;
-
+
private:
size_t fRAMBudget;
size_t fRAMUsed;
-
+
int fCount;
SkImageRef* fHead, *fTail;
-
+
int computeCount() const;
-
+
friend class SkImageRef_GlobalPool;
-
+
void justAddedPixels(SkImageRef*);
void canLosePixels(SkImageRef*);
void purgeIfNeeded();
diff --git a/src/images/SkImageRef_GlobalPool.cpp b/src/images/SkImageRef_GlobalPool.cpp
index bd63f72..a5a71a3 100644
--- a/src/images/SkImageRef_GlobalPool.cpp
+++ b/src/images/SkImageRef_GlobalPool.cpp
@@ -56,10 +56,10 @@
}
return true;
}
-
+
void SkImageRef_GlobalPool::onUnlockPixels() {
this->INHERITED::onUnlockPixels();
-
+
// by design, onUnlockPixels() already is inside the mutex-lock
GetGlobalPool()->canLosePixels(this);
}
@@ -87,7 +87,7 @@
}
size_t SkImageRef_GlobalPool::GetRAMUsed() {
- SkAutoMutexAcquire ac(gImageRefMutex);
+ SkAutoMutexAcquire ac(gImageRefMutex);
return GetGlobalPool()->getRAMUsed();
}
diff --git a/src/images/SkMovie.cpp b/src/images/SkMovie.cpp
index 978cd16..e671950 100644
--- a/src/images/SkMovie.cpp
+++ b/src/images/SkMovie.cpp
@@ -57,7 +57,7 @@
SkMSec dur = this->duration();
if (time > dur)
time = dur;
-
+
bool changed = false;
if (time != fCurrTime)
{
diff --git a/src/images/SkMovie_gif.cpp b/src/images/SkMovie_gif.cpp
index 91d3591..9cebc0f 100644
--- a/src/images/SkMovie_gif.cpp
+++ b/src/images/SkMovie_gif.cpp
@@ -25,7 +25,7 @@
virtual bool onGetInfo(Info*);
virtual bool onSetTime(SkMSec);
virtual bool onGetBitmap(SkBitmap*);
-
+
private:
GifFileType* fGIF;
int fCurrIndex;
diff --git a/src/images/SkPageFlipper.cpp b/src/images/SkPageFlipper.cpp
index 8e51e63..4fd8632 100644
--- a/src/images/SkPageFlipper.cpp
+++ b/src/images/SkPageFlipper.cpp
@@ -32,7 +32,7 @@
void SkPageFlipper::resize(int width, int height) {
fWidth = width;
fHeight = height;
-
+
// this is the opposite of the constructors
fDirty1->setRect(0, 0, width, height);
fDirty0->setEmpty();
diff --git a/src/images/SkScaledBitmapSampler.cpp b/src/images/SkScaledBitmapSampler.cpp
index 15633d3..25b32fd 100644
--- a/src/images/SkScaledBitmapSampler.cpp
+++ b/src/images/SkScaledBitmapSampler.cpp
@@ -302,7 +302,7 @@
if (width <= 0 || height <= 0) {
sk_throw();
}
-
+
if (sampleSize <= 1) {
fScaledWidth = width;
fScaledHeight = height;
@@ -310,25 +310,25 @@
fDX = fDY = 1;
return;
}
-
+
int dx = SkMin32(sampleSize, width);
int dy = SkMin32(sampleSize, height);
-
+
fScaledWidth = width / dx;
fScaledHeight = height / dy;
-
+
SkASSERT(fScaledWidth > 0);
SkASSERT(fScaledHeight > 0);
-
+
fX0 = dx >> 1;
fY0 = dy >> 1;
-
+
SkASSERT(fX0 >= 0 && fX0 < width);
SkASSERT(fY0 >= 0 && fY0 < height);
-
+
fDX = dx;
fDY = dy;
-
+
SkASSERT(fDX > 0 && (fX0 + fDX * (fScaledWidth - 1)) < width);
SkASSERT(fDY > 0 && (fY0 + fDY * (fScaledHeight - 1)) < height);
}
@@ -413,7 +413,7 @@
default:
return false;
}
-
+
fRowProc = gProcs[index];
fDstRow = (char*)dst->getPixels();
fDstRowBytes = dst->rowBytes();
diff --git a/src/images/SkScaledBitmapSampler.h b/src/images/SkScaledBitmapSampler.h
index 8a735df..f6de4cc 100644
--- a/src/images/SkScaledBitmapSampler.h
+++ b/src/images/SkScaledBitmapSampler.h
@@ -16,10 +16,10 @@
class SkScaledBitmapSampler {
public:
SkScaledBitmapSampler(int origWidth, int origHeight, int cellSize);
-
+
int scaledWidth() const { return fScaledWidth; }
int scaledHeight() const { return fScaledHeight; }
-
+
int srcY0() const { return fY0; }
int srcDY() const { return fDY; }
@@ -59,7 +59,7 @@
char* fDstRow; // points into bitmap's pixels
int fDstRowBytes;
int fCurrY; // used for dithering
- int fSrcPixelSize; // 1, 3, 4
+ int fSrcPixelSize; // 1, 3, 4
RowProc fRowProc;
// optional reference to the src colors if the src is a palette model
diff --git a/src/images/bmpdecoderhelper.h b/src/images/bmpdecoderhelper.h
index f3324ee..f2f4109 100644
--- a/src/images/bmpdecoderhelper.h
+++ b/src/images/bmpdecoderhelper.h
@@ -32,14 +32,14 @@
~scoped_array() {
delete[] ptr_;
}
-
+
void reset(T* p = 0) {
if (p != ptr_) {
delete[] ptr_;
ptr_ = p;
}
}
-
+
T& operator[](int i) const {
return ptr_[i];
}
@@ -53,7 +53,7 @@
public:
BmpDecoderCallback() { }
virtual ~BmpDecoderCallback() {}
-
+
/**
* This is called once for an image. It is passed the width and height and
* should return the address of a buffer that is large enough to store
@@ -62,7 +62,7 @@
* valid dimensions.
*/
virtual uint8* SetSize(int width, int height) = 0;
-
+
private:
DISALLOW_EVIL_CONSTRUCTORS(BmpDecoderCallback);
};
@@ -110,7 +110,7 @@
uint8* output_;
bool inverted_;
};
-
+
} // namespace
#endif