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

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: 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
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 * This constructor will duplicate this stream.
32 */
33 explicit SkDecodingImageGenerator(SkStreamRewindable* stream);
34
27 virtual ~SkDecodingImageGenerator(); 35 virtual ~SkDecodingImageGenerator();
28 36
29 virtual SkData* refEncodedData() SK_OVERRIDE; 37 virtual SkData* refEncodedData() SK_OVERRIDE;
30 38
31 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE; 39 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE;
32 40
33 virtual bool getPixels(const SkImageInfo& info, 41 virtual bool getPixels(const SkImageInfo& info,
34 void* pixels, 42 void* pixels,
35 size_t rowBytes) SK_OVERRIDE; 43 size_t rowBytes) SK_OVERRIDE;
36 44
37 /** 45 /**
38 * Install the SkData into the destination bitmap, using a new 46 * Install the SkData into the destination bitmap, using a new
39 * SkDiscardablePixelRef and a new SkDecodingImageGenerator. 47 * SkDiscardablePixelRef and a new SkDecodingImageGenerator.
40 * 48 *
41 * @param data Contains the encoded image data that will be used 49 * @param data Contains the encoded image data that will be used
42 * by the SkDecodingImageGenerator. Will be ref()ed. 50 * by the SkDecodingImageGenerator. Will be ref()ed.
43 * 51 *
44 * @param destination Upon success, this bitmap will be 52 * @param destination Upon success, this bitmap will be
45 * configured and have a pixelref installed. 53 * configured and have a pixelref installed.
46 * 54 *
47 * @param factory If not NULL, this object will be used as a 55 * @param factory If not NULL, this object will be used as a
48 * source of discardable memory when decoding. If NULL, then 56 * source of discardable memory when decoding. If NULL, then
49 * SkDiscardableMemory::Create() will be called. 57 * SkDiscardableMemory::Create() will be called.
50 * 58 *
51 * @return true iff successful. 59 * @return true iff successful.
52 */ 60 */
53 static bool Install(SkData* data, SkBitmap* destination, 61 static bool Install(SkData* data, SkBitmap* destination,
54 SkDiscardableMemory::Factory* factory = NULL); 62 SkDiscardableMemory::Factory* factory = NULL);
63 static bool Install(SkStreamRewindable* stream, SkBitmap* destination,
64 SkDiscardableMemory::Factory* factory = NULL);
55 65
56 private: 66 private:
57 SkData* fData; 67 SkData* fData;
68 SkStreamRewindable* fStream;
69 SkImageInfo fInfo;
70 bool fHasInfo;
71 bool fDoCopyTo;
58 }; 72 };
59 #endif // SkDecodingImageGenerator_DEFINED 73 #endif // SkDecodingImageGenerator_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698