| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
| 9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
| 10 #include "SkCodecPriv.h" | 10 #include "SkCodecPriv.h" |
| 11 #include "SkData.h" | 11 #include "SkData.h" |
| 12 #include "SkGifCodec.h" | 12 #include "SkGifCodec.h" |
| 13 #include "SkIcoCodec.h" | 13 #include "SkIcoCodec.h" |
| 14 #if !defined(GOOGLE3) | 14 #if !defined(GOOGLE3) |
| 15 #include "SkJpegCodec.h" | 15 #include "SkJpegCodec.h" |
| 16 #endif | 16 #endif |
| 17 #include "SkPngCodec.h" | 17 #include "SkPngCodec.h" |
| 18 #ifdef SK_CODEC_DECODES_RAW | |
| 19 #include "SkRawCodec.h" | |
| 20 #endif | |
| 21 #include "SkStream.h" | 18 #include "SkStream.h" |
| 22 #include "SkWbmpCodec.h" | 19 #include "SkWbmpCodec.h" |
| 23 #include "SkWebpCodec.h" | 20 #include "SkWebpCodec.h" |
| 24 | 21 |
| 25 struct DecoderProc { | 22 struct DecoderProc { |
| 26 bool (*IsFormat)(const void*, size_t); | 23 bool (*IsFormat)(const void*, size_t); |
| 27 SkCodec* (*NewFromStream)(SkStream*); | 24 SkCodec* (*NewFromStream)(SkStream*); |
| 28 }; | 25 }; |
| 29 | 26 |
| 30 static const DecoderProc gDecoderProcs[] = { | 27 static const DecoderProc gDecoderProcs[] = { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // PNG is special, since we want to be able to supply an SkPngChunkReader. | 79 // PNG is special, since we want to be able to supply an SkPngChunkReader. |
| 83 // But this code follows the same pattern as the loop. | 80 // But this code follows the same pattern as the loop. |
| 84 if (SkPngCodec::IsPng(buffer, bytesRead)) { | 81 if (SkPngCodec::IsPng(buffer, bytesRead)) { |
| 85 return SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader); | 82 return SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader); |
| 86 } else { | 83 } else { |
| 87 for (DecoderProc proc : gDecoderProcs) { | 84 for (DecoderProc proc : gDecoderProcs) { |
| 88 if (proc.IsFormat(buffer, bytesRead)) { | 85 if (proc.IsFormat(buffer, bytesRead)) { |
| 89 return proc.NewFromStream(streamDeleter.detach()); | 86 return proc.NewFromStream(streamDeleter.detach()); |
| 90 } | 87 } |
| 91 } | 88 } |
| 92 | |
| 93 #ifdef SK_CODEC_DECODES_RAW | |
| 94 // Try to treat the input as RAW if all the other checks failed. | |
| 95 return SkRawCodec::NewFromStream(streamDeleter.detach()); | |
| 96 #endif | |
| 97 } | 89 } |
| 98 | 90 |
| 99 return nullptr; | 91 return nullptr; |
| 100 } | 92 } |
| 101 | 93 |
| 102 SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) { | 94 SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) { |
| 103 if (!data) { | 95 if (!data) { |
| 104 return nullptr; | 96 return nullptr; |
| 105 } | 97 } |
| 106 return NewFromStream(new SkMemoryStream(data), reader); | 98 return NewFromStream(new SkMemoryStream(data), reader); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); | 366 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); |
| 375 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); | 367 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); |
| 376 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { | 368 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { |
| 377 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); | 369 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); |
| 378 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); | 370 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); |
| 379 } | 371 } |
| 380 break; | 372 break; |
| 381 } | 373 } |
| 382 } | 374 } |
| 383 } | 375 } |
| OLD | NEW |