Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: src/codec/SkCodec.cpp

Issue 1520403003: Prototype of RAW decoding in Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge the change for DEPS Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "SkData.h" 10 #include "SkData.h"
11 #include "SkCodec_libgif.h" 11 #include "SkCodec_libgif.h"
12 #include "SkCodec_libico.h" 12 #include "SkCodec_libico.h"
13 #include "SkCodec_libpng.h" 13 #include "SkCodec_libpng.h"
14 #include "SkCodec_wbmp.h" 14 #include "SkCodec_wbmp.h"
15 #include "SkCodecPriv.h" 15 #include "SkCodecPriv.h"
16 #if !defined(GOOGLE3) 16 #if !defined(GOOGLE3)
17 #include "SkJpegCodec.h" 17 #include "SkJpegCodec.h"
18 #endif 18 #endif
19 #include "SkStream.h" 19 #include "SkStream.h"
20 #include "SkWebpCodec.h" 20 #include "SkWebpCodec.h"
21 #include "SkRawCodec.h"
21 22
22 struct DecoderProc { 23 struct DecoderProc {
23 bool (*IsFormat)(const void*, size_t); 24 bool (*IsFormat)(const void*, size_t);
24 SkCodec* (*NewFromStream)(SkStream*); 25 SkCodec* (*NewFromStream)(SkStream*);
25 }; 26 };
26 27
27 static const DecoderProc gDecoderProcs[] = { 28 static const DecoderProc gDecoderProcs[] = {
28 #if !defined(GOOGLE3) 29 #if !defined(GOOGLE3)
29 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream }, 30 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream },
30 #endif 31 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // But this code follows the same pattern as the loop. 79 // But this code follows the same pattern as the loop.
79 if (SkPngCodec::IsPng(buffer, bytesRead)) { 80 if (SkPngCodec::IsPng(buffer, bytesRead)) {
80 codec.reset(SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReade r)); 81 codec.reset(SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReade r));
81 } else { 82 } else {
82 for (DecoderProc proc : gDecoderProcs) { 83 for (DecoderProc proc : gDecoderProcs) {
83 if (proc.IsFormat(buffer, bytesRead)) { 84 if (proc.IsFormat(buffer, bytesRead)) {
84 codec.reset(proc.NewFromStream(streamDeleter.detach())); 85 codec.reset(proc.NewFromStream(streamDeleter.detach()));
85 break; 86 break;
86 } 87 }
87 } 88 }
89
90 // Try to treat the input as RAW if all the other checks failed.
91 if (!codec) {
scroggo 2016/01/07 13:53:20 I think this is a TAB? We use spaces instead.
yujieqin 2016/01/07 15:52:01 Done.
92 codec.reset(SkRawCodec::NewFromStream(streamDeleter.detach()));
93 }
88 } 94 }
89 95
90 // Set the max size at 128 megapixels (512 MB for kN32). 96 // Set the max size at 128 megapixels (512 MB for kN32).
91 // This is about 4x smaller than a test image that takes a few minutes for 97 // This is about 4x smaller than a test image that takes a few minutes for
92 // dm to decode and draw. 98 // dm to decode and draw.
93 const int32_t maxSize = 1 << 27; 99 const int32_t maxSize = 1 << 27;
94 if (codec && codec->getInfo().width() * codec->getInfo().height() > maxSize) { 100 if (codec && codec->getInfo().width() * codec->getInfo().height() > maxSize) {
95 SkCodecPrintf("Error: Image size too large, cannot decode.\n"); 101 SkCodecPrintf("Error: Image size too large, cannot decode.\n");
96 return nullptr; 102 return nullptr;
97 } else { 103 } else {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested); 380 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested);
375 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); 381 const SkImageInfo fillInfo = info.makeWH(info.width(), 1);
376 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { 382 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
377 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes); 383 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes);
378 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler); 384 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler);
379 } 385 }
380 break; 386 break;
381 } 387 }
382 } 388 }
383 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698