Some codec code formatting cleanup.

While looking at users of SkTAddOffset, some unwanted casts were
found. These casts are removed and the lines reformatted. However,
the formatting of the rest of the file was unhappy, so this is really
just a formatting clean-up.

Review URL: https://codereview.chromium.org/1301393010
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index 9af19d1..1bd1409 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -209,8 +209,7 @@
     // Set the pixel based on destination color type
     switch (dstInfo.colorType()) {
         case kN32_SkColorType: {
-            SkPMColor* dstRow = SkTAddOffset<SkPMColor>((SkPMColor*) dst,
-                    row * (int) dstRowBytes);
+            SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
             dstRow[x] = fColorTable->operator[](index);
             break;
         }
@@ -246,8 +245,7 @@
     // Set the pixel based on destination color type
     switch (dstInfo.colorType()) {
         case kN32_SkColorType: {
-            SkPMColor* dstRow = SkTAddOffset<SkPMColor>((SkPMColor*) dst,
-                    row * (int) dstRowBytes);
+            SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
             dstRow[x] = SkPackARGB32NoCheck(0xFF, red, green, blue);
             break;
         }
@@ -434,8 +432,7 @@
                 uint8_t green = fStreamBuffer.get()[fCurrRLEByte++];
                 uint8_t red = fStreamBuffer.get()[fCurrRLEByte++];
                 while (x < endX) {
-                    setRGBPixel(dst, dstRowBytes, dstInfo, x++, y, red,
-                            green, blue);
+                    setRGBPixel(dst, dstRowBytes, dstInfo, x++, y, red, green, blue);
                 }
             } else {
                 // In RLE8 or RLE4, the second byte read gives the index in the
@@ -451,8 +448,7 @@
 
                 // Set the indicated number of pixels
                 for (int which = 0; x < endX; x++) {
-                    setPixel(dst, dstRowBytes, dstInfo, x, y,
-                            indices[which]);
+                    setPixel(dst, dstRowBytes, dstInfo, x, y, indices[which]);
                     which = !which;
                 }
             }
diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp
index 250a0d6..20a5572 100644
--- a/src/codec/SkCodec_libgif.cpp
+++ b/src/codec/SkCodec_libgif.cpp
@@ -21,8 +21,9 @@
     char buf[GIF_STAMP_LEN];
     if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
         if (memcmp(GIF_STAMP,   buf, GIF_STAMP_LEN) == 0 ||
-                memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
-                memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
+            memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
+            memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0)
+        {
             return true;
         }
     }
@@ -39,8 +40,7 @@
 /*
  * Error function
  */
-static SkCodec::Result gif_error(const char* msg,
-        SkCodec::Result result = SkCodec::kInvalidInput) {
+static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCodec::kInvalidInput) {
     SkCodecPrintf("Gif Error: %s\n", msg);
     return result;
 }
@@ -49,8 +49,7 @@
 /*
  * Read function that will be passed to gif_lib
  */
-static int32_t read_bytes_callback(GifFileType* fileType, GifByteType* out,
-        int32_t size) {
+static int32_t read_bytes_callback(GifFileType* fileType, GifByteType* out, int32_t size) {
     SkStream* stream = (SkStream*) fileType->UserData;
     return (int32_t) stream->read(out, size);
 }
@@ -96,8 +95,7 @@
         // graphics control extension is always four bytes.  The fourth byte
         // is the transparent index (if it exists), so we need at least four
         // bytes.
-        if (GRAPHICS_EXT_FUNC_CODE == extBlock.Function &&
-                extBlock.ByteCount >= 4) {
+        if (GRAPHICS_EXT_FUNC_CODE == extBlock.Function && extBlock.ByteCount >= 4) {
 
             // Check the transparent color flag which indicates whether a
             // transparent index exists.  It is the least significant bit of
@@ -169,7 +167,7 @@
         // kPremul because we support kPremul, and it is more efficient to
         // use kPremul directly even when kUnpremul is supported.
         const SkImageInfo& imageInfo = SkImageInfo::Make(width, height,
-                kIndex_8_SkColorType, kPremul_SkAlphaType);
+                                                         kIndex_8_SkColorType, kPremul_SkAlphaType);
         *codecOut = new SkGifCodec(imageInfo, streamDeleter.detach(), gif.detach());
     } else {
         SkASSERT(nullptr != gifOut);
@@ -192,8 +190,7 @@
     return nullptr;
 }
 
-SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream,
-                       GifFileType* gif)
+SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif)
     : INHERITED(srcInfo, stream)
     , fGif(gif)
 {}
@@ -231,8 +228,7 @@
         return gif_error("Scaling not supported.\n", kInvalidScale);
     }
     if (!conversion_possible(dstInfo, this->getInfo())) {
-        return gif_error("Cannot convert input type to output type.\n",
-                kInvalidConversion);
+        return gif_error("Cannot convert input type to output type.\n", kInvalidConversion);
     }
 
     // Use this as a container to hold information about any gif extension
@@ -260,8 +256,7 @@
             case IMAGE_DESC_RECORD_TYPE: {
                 // Read the image descriptor
                 if (GIF_ERROR == DGifGetImageDesc(fGif)) {
-                    return gif_error("DGifGetImageDesc failed.\n",
-                            kInvalidInput);
+                    return gif_error("DGifGetImageDesc failed.\n", kInvalidInput);
                 }
 
                 // If reading the image descriptor is successful, the image
@@ -277,8 +272,7 @@
                 int32_t innerHeight = desc.Height;
                 // Fail on non-positive dimensions
                 if (innerWidth <= 0 || innerHeight <= 0) {
-                    return gif_error("Invalid dimensions for inner image.\n",
-                            kInvalidInput);
+                    return gif_error("Invalid dimensions for inner image.\n", kInvalidInput);
                 }
                 // Treat the following cases as warnings and try to fix
                 if (innerWidth > width) {
@@ -327,8 +321,7 @@
                 }
                 if (nullptr != colorMap) {
                     colorCount = colorMap->ColorCount;
-                    SkASSERT(colorCount ==
-                            (unsigned) (1 << (colorMap->BitsPerPixel)));
+                    SkASSERT(colorCount == (unsigned) (1 << (colorMap->BitsPerPixel)));
                     SkASSERT(colorCount <= 256);
                     for (uint32_t i = 0; i < colorCount; i++) {
                         colorTable[i] = SkPackARGB32(0xFF,
@@ -384,24 +377,21 @@
                 if (innerWidth < width || innerHeight < height) {
 
                     // Modify the destination info
-                    const SkImageInfo subsetDstInfo =
-                            dstInfo.makeWH(innerWidth, innerHeight);
+                    const SkImageInfo subsetDstInfo = dstInfo.makeWH(innerWidth, innerHeight);
 
                     // Fill the destination with the fill color
                     // FIXME: This may not be the behavior that we want for
                     //        animated gifs where we draw on top of the
                     //        previous frame.
                     if (!skipBackground) {
-                        SkSwizzler::Fill(dst, dstInfo, dstRowBytes, height,
-                                fillIndex, colorTable);
+                        SkSwizzler::Fill(dst, dstInfo, dstRowBytes, height, fillIndex, colorTable);
                     }
 
                     // Modify the dst pointer
-                    const int32_t dstBytesPerPixel =
-                            SkColorTypeBytesPerPixel(dstColorType);
+                    const int32_t dstBytesPerPixel = SkColorTypeBytesPerPixel(dstColorType);
                     dst = SkTAddOffset<void*>(dst,
-                            dstRowBytes * imageTop +
-                            dstBytesPerPixel * imageLeft);
+                                              dstRowBytes * imageTop +
+                                              dstBytesPerPixel * imageLeft);
 
                     // Create the subset swizzler
                     swizzler.reset(SkSwizzler::CreateSwizzler(
@@ -424,14 +414,13 @@
                     // the rearranging.
                     SkGifInterlaceIter iter(innerHeight);
                     for (int32_t y = 0; y < innerHeight; y++) {
-                        if (GIF_ERROR == DGifGetLine(fGif, buffer.get(),
-                                innerWidth)) {
+                        if (GIF_ERROR == DGifGetLine(fGif, buffer.get(), innerWidth)) {
                             // Recover from error by filling remainder of image
                             if (!skipBackground) {
                                 memset(buffer.get(), fillIndex, innerWidth);
                                 for (; y < innerHeight; y++) {
                                     void* dstRow = SkTAddOffset<void>(dst,
-                                            dstRowBytes * iter.nextY());
+                                                                      dstRowBytes * iter.nextY());
                                     swizzler->swizzle(dstRow, buffer.get());
                                 }
                             }
@@ -439,19 +428,17 @@
                                     "Could not decode line %d of %d.\n",
                                     y, height - 1).c_str(), kIncompleteInput);
                         }
-                        void* dstRow = SkTAddOffset<void>(
-                                dst, dstRowBytes * iter.nextY());
+                        void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * iter.nextY());
                         swizzler->swizzle(dstRow, buffer.get());
                     }
                 } else {
                     // Standard mode
                     void* dstRow = dst;
                     for (int32_t y = 0; y < innerHeight; y++) {
-                        if (GIF_ERROR == DGifGetLine(fGif, buffer.get(),
-                                innerWidth)) {
+                        if (GIF_ERROR == DGifGetLine(fGif, buffer.get(), innerWidth)) {
                             if (!skipBackground) {
                                 SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes,
-                                        innerHeight - y, fillIndex, colorTable);
+                                                 innerHeight - y, fillIndex, colorTable);
                             }
                             return gif_error(SkStringPrintf(
                                     "Could not decode line %d of %d.\n",
@@ -490,26 +477,22 @@
             // such as transparency or animation.
             case EXTENSION_RECORD_TYPE:
                 // Read extension data
-                if (GIF_ERROR ==
-                        DGifGetExtension(fGif, &extFunction, &extData)) {
-                    return gif_error("Could not get extension.\n",
-                            kIncompleteInput);
+                if (GIF_ERROR == DGifGetExtension(fGif, &extFunction, &extData)) {
+                    return gif_error("Could not get extension.\n", kIncompleteInput);
                 }
 
                 // Create an extension block with our data
                 while (nullptr != extData) {
                     // Add a single block
-                    if (GIF_ERROR ==
-                            GifAddExtensionBlock(&saveExt.ExtensionBlockCount,
-                            &saveExt.ExtensionBlocks, extFunction, extData[0],
-                            &extData[1])) {
-                        return gif_error("Could not add extension block.\n",
-                                kIncompleteInput);
+                    if (GIF_ERROR == GifAddExtensionBlock(&saveExt.ExtensionBlockCount,
+                                                          &saveExt.ExtensionBlocks,
+                                                          extFunction, extData[0], &extData[1]))
+                    {
+                        return gif_error("Could not add extension block.\n", kIncompleteInput);
                     }
                     // Move to the next block
                     if (GIF_ERROR == DGifGetExtensionNext(fGif, &extData)) {
-                        return gif_error("Could not get next extension.\n",
-                                kIncompleteInput);
+                        return gif_error("Could not get next extension.\n", kIncompleteInput);
                     }
                 }
                 break;
@@ -526,6 +509,5 @@
         }
     } while (TERMINATE_RECORD_TYPE != recordType);
 
-    return gif_error("Could not find any images to decode in gif file.\n",
-            kInvalidInput);
+    return gif_error("Could not find any images to decode in gif file.\n", kInvalidInput);
 }