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

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

Issue 226253003: Change SkDecodingImageGenerator to hide implementation details. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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 | « no previous file | 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 "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkImageGenerator.h" 12 #include "SkImageGenerator.h"
13 13
14 class SkData; 14 class SkData;
15 class SkStreamRewindable; 15 class SkStreamRewindable;
16 16
17 /** 17 /**
18 * An implementation of SkImageGenerator that calls into 18 * An implementation of SkImageGenerator that calls into
19 * SkImageDecoder. 19 * SkImageDecoder.
20 */ 20 */
21 class SkDecodingImageGenerator : public SkImageGenerator { 21 namespace SkDecodingImageGenerator {
reed2 2014/04/04 20:59:51 Why namespace instead of class? Other examples in
22 public:
23 virtual ~SkDecodingImageGenerator();
24 virtual SkData* refEncodedData() SK_OVERRIDE;
25 // This implementaion of getInfo() always returns true.
26 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE;
27 virtual bool getPixels(const SkImageInfo& info,
28 void* pixels,
29 size_t rowBytes) SK_OVERRIDE;
30 /** 22 /**
31 * These options will be passed on to the image decoder. The 23 * These options will be passed on to the image decoder. The
32 * defaults are sensible. 24 * defaults are sensible.
33 * 25 *
34 * @param fSampleSize If set to > 1, tells the decoder to return a 26 * @param fSampleSize If set to > 1, tells the decoder to return a
35 * smaller than original bitmap, sampling 1 pixel for 27 * smaller than original bitmap, sampling 1 pixel for
36 * every size pixels. e.g. if sample size is set to 3, 28 * every size pixels. e.g. if sample size is set to 3,
37 * then the returned bitmap will be 1/3 as wide and high, 29 * then the returned bitmap will be 1/3 as wide and high,
38 * and will contain 1/9 as many pixels as the original. 30 * and will contain 1/9 as many pixels as the original.
39 * Note: this is a hint, and the codec may choose to 31 * Note: this is a hint, and the codec may choose to
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 * SkImageGenerator* gen 82 * SkImageGenerator* gen
91 * = SkDecodingImageGenerator::Create( 83 * = SkDecodingImageGenerator::Create(
92 * stream->duplicate(), SkDecodingImageGenerator::Options()); 84 * stream->duplicate(), SkDecodingImageGenerator::Options());
93 * ... 85 * ...
94 * SkDELETE(gen); 86 * SkDELETE(gen);
95 * 87 *
96 * @param Options (see above) 88 * @param Options (see above)
97 * 89 *
98 * @return NULL on failure, a new SkImageGenerator on success. 90 * @return NULL on failure, a new SkImageGenerator on success.
99 */ 91 */
100 static SkImageGenerator* Create(SkStreamRewindable* stream, 92 SkImageGenerator* Create(SkStreamRewindable* stream,
101 const Options& opt); 93 const Options& opt);
102 94
103 /** 95 /**
104 * @param data Contains the encoded image data that will be used by 96 * @param data Contains the encoded image data that will be used by
105 * the SkDecodingImageGenerator. Will be ref()ed by the 97 * the SkDecodingImageGenerator. Will be ref()ed by the
106 * SkImageGenerator constructor and and unref()ed on deletion. 98 * SkImageGenerator constructor and and unref()ed on deletion.
107 */ 99 */
108 static SkImageGenerator* Create(SkData* data, const Options& opt); 100 SkImageGenerator* Create(SkData* data, const Options& opt);
109
110 private:
111 SkData* fData;
112 SkStreamRewindable* fStream;
113 const SkImageInfo fInfo;
114 const int fSampleSize;
115 const bool fDitherImage;
116
117 SkDecodingImageGenerator(SkData* data,
118 SkStreamRewindable* stream,
119 const SkImageInfo& info,
120 int sampleSize,
121 bool ditherImage);
122 static SkImageGenerator* Create(SkData*, SkStreamRewindable*,
123 const Options&);
124 typedef SkImageGenerator INHERITED;
125 }; 101 };
126 102
127 // // Example of most basic use case: 103 // // Example of most basic use case:
128 // 104 //
129 // bool install_data(SkData* data, SkBitmap* dst) { 105 // bool install_data(SkData* data, SkBitmap* dst) {
130 // return SkInstallDiscardablePixelRef( 106 // return SkInstallDiscardablePixelRef(
131 // SkDecodingImageGenerator::Create( 107 // SkDecodingImageGenerator::Create(
132 // data, SkDecodingImageGenerator::Options()), dst, NULL); 108 // data, SkDecodingImageGenerator::Options()), dst, NULL);
133 // } 109 // }
134 // bool install_stream(SkStreamRewindable* stream, SkBitmap* dst) { 110 // bool install_stream(SkStreamRewindable* stream, SkBitmap* dst) {
135 // return SkInstallDiscardablePixelRef( 111 // return SkInstallDiscardablePixelRef(
136 // SkDecodingImageGenerator::Create( 112 // SkDecodingImageGenerator::Create(
137 // stream, SkDecodingImageGenerator::Options()), dst, NULL); 113 // stream, SkDecodingImageGenerator::Options()), dst, NULL);
138 // } 114 // }
139 115
140 #endif // SkDecodingImageGenerator_DEFINED 116 #endif // SkDecodingImageGenerator_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698