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

Side by Side Diff: include/codec/SkCodec.h

Issue 1472123002: Make SkCodec support peek() and read() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years 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 | « no previous file | src/codec/SkBmpCodec.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 #ifndef SkCodec_DEFINED 8 #ifndef SkCodec_DEFINED
9 #define SkCodec_DEFINED 9 #define SkCodec_DEFINED
10 10
11 #include "../private/SkTemplates.h" 11 #include "../private/SkTemplates.h"
12 #include "SkColor.h" 12 #include "SkColor.h"
13 #include "SkEncodedFormat.h" 13 #include "SkEncodedFormat.h"
14 #include "SkImageInfo.h" 14 #include "SkImageInfo.h"
15 #include "SkSize.h" 15 #include "SkSize.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "SkTypes.h" 17 #include "SkTypes.h"
18 18
19 class SkData; 19 class SkData;
20 class SkPngChunkReader; 20 class SkPngChunkReader;
21 class SkSampler; 21 class SkSampler;
22 22
23 /** 23 /**
24 * Abstraction layer directly on top of an image codec. 24 * Abstraction layer directly on top of an image codec.
25 */ 25 */
26 class SkCodec : SkNoncopyable { 26 class SkCodec : SkNoncopyable {
27 public: 27 public:
28 /** 28 /**
29 * Minimum number of bytes that must be buffered in SkStream input.
30 *
31 * An SkStream passed to NewFromStream must be able to use this many
32 * bytes to determine the image type. Then the same SkStream must be
33 * passed to the correct decoder to read from the beginning.
34 *
35 * This can be accomplished by implementing peek() to support peeking
36 * this many bytes, or by implementing rewind() to be able to rewind()
37 * after reading this many bytes.
38 */
39 static size_t MinBufferedBytesNeeded();
40
41 /**
29 * If this stream represents an encoded image that we know how to decode, 42 * If this stream represents an encoded image that we know how to decode,
30 * return an SkCodec that can decode it. Otherwise return NULL. 43 * return an SkCodec that can decode it. Otherwise return NULL.
31 * 44 *
45 * As stated above, this call must be able to peek or read
46 * MinBufferedBytesNeeded to determine the correct format, and then start
47 * reading from the beginning. First it will attempt to peek, and it
48 * assumes that if less than MinBufferedBytesNeeded bytes (but more than
49 * zero) are returned, this is because the stream is shorter than this,
50 * so falling back to reading would not provide more data. If peek()
51 * returns zero bytes, this call will instead attempt to read(). This
52 * will require that the stream can be rewind()ed.
53 *
54 * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if
55 * the image is a png.
56 *
32 * If the SkPngChunkReader is not NULL then: 57 * If the SkPngChunkReader is not NULL then:
33 * If the image is not a PNG, the SkPngChunkReader will be ignored. 58 * If the image is not a PNG, the SkPngChunkReader will be ignored.
34 * If the image is a PNG, the SkPngChunkReader will be reffed. 59 * If the image is a PNG, the SkPngChunkReader will be reffed.
35 * If the PNG has unknown chunks, the SkPngChunkReader will be used 60 * If the PNG has unknown chunks, the SkPngChunkReader will be used
36 * to handle these chunks. SkPngChunkReader will be called to read 61 * to handle these chunks. SkPngChunkReader will be called to read
37 * any unknown chunk at any point during the creation of the codec 62 * any unknown chunk at any point during the creation of the codec
38 * or the decode. Note that if SkPngChunkReader fails to read a 63 * or the decode. Note that if SkPngChunkReader fails to read a
39 * chunk, this could result in a failure to create the codec or a 64 * chunk, this could result in a failure to create the codec or a
40 * failure to decode the image. 65 * failure to decode the image.
41 * If the PNG does not contain unknown chunks, the SkPngChunkReader 66 * If the PNG does not contain unknown chunks, the SkPngChunkReader
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 * not affect ownership. 641 * not affect ownership.
617 * 642 *
618 * Only valid during scanline decoding. 643 * Only valid during scanline decoding.
619 */ 644 */
620 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } 645 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
621 646
622 friend class SkSampledCodec; 647 friend class SkSampledCodec;
623 friend class SkIcoCodec; 648 friend class SkIcoCodec;
624 }; 649 };
625 #endif // SkCodec_DEFINED 650 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkBmpCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698