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

Side by Side Diff: src/images/SkDecodingImageGenerator.h

Issue 101973005: SkDecodingImageGenerator now uses SkStreamRewindable (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebased again Created 7 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('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 2013 Google Inc. 2 * Copyright 2013 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 SkDecodingImageGenerator_DEFINED 8 #ifndef SkDecodingImageGenerator_DEFINED
9 #define SkDecodingImageGenerator_DEFINED 9 #define SkDecodingImageGenerator_DEFINED
10 10
11 #include "SkDiscardableMemory.h" 11 #include "SkDiscardableMemory.h"
12 #include "SkImageGenerator.h" 12 #include "SkImageGenerator.h"
13 #include "SkImageInfo.h"
13 14
14 class SkBitmap; 15 class SkBitmap;
16 class SkStreamRewindable;
15 17
16 /** 18 /**
17 * Calls into SkImageDecoder::DecodeMemoryToTarget to implement a 19 * Calls into SkImageDecoder::DecodeMemoryToTarget to implement a
18 * SkImageGenerator 20 * SkImageGenerator
19 */ 21 */
20 class SkDecodingImageGenerator : public SkImageGenerator { 22 class SkDecodingImageGenerator : public SkImageGenerator {
21 public: 23 public:
22 /* 24 /*
23 * The constructor will take a reference to the SkData. The 25 * The constructor will take a reference to the SkData. The
24 * destructor will unref() it. 26 * destructor will unref() it.
25 */ 27 */
26 SkDecodingImageGenerator(SkData* data); 28 explicit SkDecodingImageGenerator(SkData* data);
29
30 /*
31 * The SkData version of this constructor is preferred. If the
32 * stream has an underlying SkData (such as a SkMemoryStream)
33 * pass that in.
34 *
35 * This object will unref the stream when done. Since streams
36 * have internal state (position), the caller should not pass a
37 * shared stream in. Pass either a new duplicated stream in or
38 * transfer ownership of the stream. In the latter case, be sure
39 * that there are no other consumers of the stream who will
40 * modify the stream's position. This constructor asserts
41 * stream->unique().
42 *
43 * For example:
44 * SkStreamRewindable* stream;
45 * ...
46 * SkImageGenerator* gen
47 * = SkNEW_ARGS(SkDecodingImageGenerator,
48 * (stream->duplicate()));
49 * ...
50 * SkDELETE(gen);
51 */
52 explicit SkDecodingImageGenerator(SkStreamRewindable* stream);
53
27 virtual ~SkDecodingImageGenerator(); 54 virtual ~SkDecodingImageGenerator();
28 55
29 virtual SkData* refEncodedData() SK_OVERRIDE; 56 virtual SkData* refEncodedData() SK_OVERRIDE;
30 57
31 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE; 58 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE;
32 59
33 virtual bool getPixels(const SkImageInfo& info, 60 virtual bool getPixels(const SkImageInfo& info,
34 void* pixels, 61 void* pixels,
35 size_t rowBytes) SK_OVERRIDE; 62 size_t rowBytes) SK_OVERRIDE;
36 63
37 /** 64 /**
38 * Install the SkData into the destination bitmap, using a new 65 * Install the SkData into the destination bitmap, using a new
39 * SkDiscardablePixelRef and a new SkDecodingImageGenerator. 66 * SkDiscardablePixelRef and a new SkDecodingImageGenerator.
40 * 67 *
41 * @param data Contains the encoded image data that will be used 68 * @param data Contains the encoded image data that will be used
42 * by the SkDecodingImageGenerator. Will be ref()ed. 69 * by the SkDecodingImageGenerator. Will be ref()ed.
43 * 70 *
44 * @param destination Upon success, this bitmap will be 71 * @param destination Upon success, this bitmap will be
45 * configured and have a pixelref installed. 72 * configured and have a pixelref installed.
46 * 73 *
47 * @param factory If not NULL, this object will be used as a 74 * @param factory If not NULL, this object will be used as a
48 * source of discardable memory when decoding. If NULL, then 75 * source of discardable memory when decoding. If NULL, then
49 * SkDiscardableMemory::Create() will be called. 76 * SkDiscardableMemory::Create() will be called.
50 * 77 *
51 * @return true iff successful. 78 * @return true iff successful.
52 */ 79 */
53 static bool Install(SkData* data, SkBitmap* destination, 80 static bool Install(SkData* data, SkBitmap* destination,
54 SkDiscardableMemory::Factory* factory = NULL); 81 SkDiscardableMemory::Factory* factory = NULL);
82 /**
83 * Install the stream into the destination bitmap, using a new
84 * SkDiscardablePixelRef and a new SkDecodingImageGenerator.
85 *
86 * The SkData version of this function is preferred. If the
87 * stream has an underlying SkData (such as a SkMemoryStream)
88 * pass that in.
89 *
90 * @param stream The source of encoded data that will be passed
91 * to the decoder. The installed SkDecodingImageGenerator will
92 * unref the stream when done. If false is returned, this
93 * function will perform the unref. Since streams have internal
94 * state (position), the caller should not pass a shared stream
95 * in. Pass either a new duplicated stream in or transfer
96 * ownership of the stream. In the latter case, be sure that
97 * there are no other consumers of the stream who will modify the
98 * stream's position. This function will fail if
99 * (!stream->unique()).
100 *
101 * @param destination Upon success, this bitmap will be
102 * configured and have a pixelref installed.
103 *
104 * @param factory If not NULL, this object will be used as a
105 * source of discardable memory when decoding. If NULL, then
106 * SkDiscardableMemory::Create() will be called.
107 *
108 * @return true iff successful.
109 */
110 static bool Install(SkStreamRewindable* stream, SkBitmap* destination,
111 SkDiscardableMemory::Factory* factory = NULL);
55 112
56 private: 113 private:
57 SkData* fData; 114 SkData* fData;
115 SkStreamRewindable* fStream;
116 SkImageInfo fInfo;
117 bool fHasInfo;
118 bool fDoCopyTo;
58 }; 119 };
59 #endif // SkDecodingImageGenerator_DEFINED 120 #endif // SkDecodingImageGenerator_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698