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

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

Issue 1624513003: Add RAW decoding support to Skia (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix sample_dng in resources, Treat less warnings as errors 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
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/codec/SkRawAdapterCodec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
18 #include "SkStream.h" 21 #include "SkStream.h"
19 #include "SkWbmpCodec.h" 22 #include "SkWbmpCodec.h"
20 #include "SkWebpCodec.h" 23 #include "SkWebpCodec.h"
21 24
22 struct DecoderProc { 25 struct DecoderProc {
23 bool (*IsFormat)(const void*, size_t); 26 bool (*IsFormat)(const void*, size_t);
24 SkCodec* (*NewFromStream)(SkStream*); 27 SkCodec* (*NewFromStream)(SkStream*);
25 }; 28 };
26 29
27 static const DecoderProc gDecoderProcs[] = { 30 static const DecoderProc gDecoderProcs[] = {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // PNG is special, since we want to be able to supply an SkPngChunkReader. 82 // PNG is special, since we want to be able to supply an SkPngChunkReader.
80 // But this code follows the same pattern as the loop. 83 // But this code follows the same pattern as the loop.
81 if (SkPngCodec::IsPng(buffer, bytesRead)) { 84 if (SkPngCodec::IsPng(buffer, bytesRead)) {
82 return SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader); 85 return SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader);
83 } else { 86 } else {
84 for (DecoderProc proc : gDecoderProcs) { 87 for (DecoderProc proc : gDecoderProcs) {
85 if (proc.IsFormat(buffer, bytesRead)) { 88 if (proc.IsFormat(buffer, bytesRead)) {
86 return proc.NewFromStream(streamDeleter.detach()); 89 return proc.NewFromStream(streamDeleter.detach());
87 } 90 }
88 } 91 }
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
89 } 97 }
90 98
91 return nullptr; 99 return nullptr;
92 } 100 }
93 101
94 SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) { 102 SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) {
95 if (!data) { 103 if (!data) {
96 return nullptr; 104 return nullptr;
97 } 105 }
98 return NewFromStream(new SkMemoryStream(data), reader); 106 return NewFromStream(new SkMemoryStream(data), reader);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested); 374 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested);
367 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); 375 const SkImageInfo fillInfo = info.makeWH(info.width(), 1);
368 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { 376 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
369 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes); 377 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes);
370 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler); 378 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler);
371 } 379 }
372 break; 380 break;
373 } 381 }
374 } 382 }
375 } 383 }
OLDNEW
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/codec/SkRawAdapterCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698