Chromium Code Reviews| 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 "SkCodec_libpng.h" | 10 #include "SkCodec_libpng.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 codec.reset(SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReade r)); | 83 codec.reset(SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReade r)); |
| 84 } else { | 84 } else { |
| 85 for (DecoderProc proc : gDecoderProcs) { | 85 for (DecoderProc proc : gDecoderProcs) { |
| 86 if (proc.IsFormat(buffer, bytesRead)) { | 86 if (proc.IsFormat(buffer, bytesRead)) { |
| 87 codec.reset(proc.NewFromStream(streamDeleter.detach())); | 87 codec.reset(proc.NewFromStream(streamDeleter.detach())); |
| 88 break; | 88 break; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Set the max size at 128 megapixels (512 MB for kN32). | 93 return codec.detach(); |
|
scroggo
2016/01/12 22:24:20
This seems a little strange until the SkRawCodec c
msarett
2016/01/13 16:38:58
You're right. I've fixed this.
scroggo
2016/01/13 18:35:43
It probably would've been fine to leave it. This c
| |
| 94 // This is about 4x smaller than a test image that takes a few minutes for | |
| 95 // dm to decode and draw. | |
| 96 const int32_t maxSize = 1 << 27; | |
| 97 if (codec && codec->getInfo().width() * codec->getInfo().height() > maxSize) { | |
| 98 SkCodecPrintf("Error: Image size too large, cannot decode.\n"); | |
| 99 return nullptr; | |
| 100 } else { | |
| 101 return codec.detach(); | |
| 102 } | |
| 103 } | 94 } |
| 104 | 95 |
| 105 SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) { | 96 SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) { |
| 106 if (!data) { | 97 if (!data) { |
| 107 return nullptr; | 98 return nullptr; |
| 108 } | 99 } |
| 109 return NewFromStream(new SkMemoryStream(data), reader); | 100 return NewFromStream(new SkMemoryStream(data), reader); |
| 110 } | 101 } |
| 111 | 102 |
| 112 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) | 103 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested); | 368 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested); |
| 378 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); | 369 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); |
| 379 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { | 370 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { |
| 380 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes); | 371 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes); |
| 381 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler); | 372 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler); |
| 382 } | 373 } |
| 383 break; | 374 break; |
| 384 } | 375 } |
| 385 } | 376 } |
| 386 } | 377 } |
| OLD | NEW |