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

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

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove setSampleX(), move IsInterlaced() to scanlineDecoder Created 5 years, 4 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
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 SkScanlineDecoder_DEFINED 8 #ifndef SkScanlineDecoder_DEFINED
9 #define SkScanlineDecoder_DEFINED 9 #define SkScanlineDecoder_DEFINED
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 * of the encoded data, but then never use any colors which have alpha 68 * of the encoded data, but then never use any colors which have alpha
69 * less than 100%. This function can be called *after* decoding to 69 * less than 100%. This function can be called *after* decoding to
70 * determine if such an image truly had alpha. Calling it before decoding 70 * determine if such an image truly had alpha. Calling it before decoding
71 * is undefined. 71 * is undefined.
72 * FIXME: see skbug.com/3582. 72 * FIXME: see skbug.com/3582.
73 */ 73 */
74 bool reallyHasAlpha() const { 74 bool reallyHasAlpha() const {
75 return this->onReallyHasAlpha(); 75 return this->onReallyHasAlpha();
76 } 76 }
77 77
78 /**
79 * Returns whether the image is interlaced
80 * For an interlaced image, calling getScanlines once (regardless of the cou nt
81 * used) needs to read the entire image, therefore it is inefficient to call
82 * getScanlines more than once. Instead, it should only ever be called with all the
83 * rows needed.
84 */
85 bool isInterlaced() {
86 return this->onIsInterlaced();
87 }
88
78 protected: 89 protected:
79 SkScanlineDecoder(const SkImageInfo& requested) 90 SkScanlineDecoder(const SkImageInfo& requested)
80 : fDstInfo(requested) 91 : fDstInfo(requested)
81 , fCurrScanline(0) {} 92 , fCurrScanline(0) {}
82 93
83 virtual bool onReallyHasAlpha() const { return false; } 94 virtual bool onReallyHasAlpha() const { return false; }
84 95
96 /**
97 * returns true if the image is interlaced
98 * returns false if the image is not interlaced
99 * only certain file types can have interlaced images, those of which overri de this function
100 */
101 virtual bool onIsInterlaced() { return false; }
102
85 const SkImageInfo& dstInfo() const { return fDstInfo; } 103 const SkImageInfo& dstInfo() const { return fDstInfo; }
86 104
87 private: 105 private:
88 const SkImageInfo fDstInfo; 106 const SkImageInfo fDstInfo;
89 int fCurrScanline; 107 int fCurrScanline;
90 108
91 // Naive default version just calls onGetScanlines on temp memory. 109 // Naive default version just calls onGetScanlines on temp memory.
92 virtual SkCodec::Result onSkipScanlines(int countLines) { 110 virtual SkCodec::Result onSkipScanlines(int countLines) {
93 SkAutoMalloc storage(fDstInfo.minRowBytes()); 111 SkAutoMalloc storage(fDstInfo.minRowBytes());
94 // Note that we pass 0 to rowBytes so we continue to use the same memory . 112 // Note that we pass 0 to rowBytes so we continue to use the same memory .
95 // Also note that while getScanlines checks that rowBytes is big enough, 113 // Also note that while getScanlines checks that rowBytes is big enough,
96 // onGetScanlines bypasses that check. 114 // onGetScanlines bypasses that check.
97 // Calling the virtual method also means we do not double count 115 // Calling the virtual method also means we do not double count
98 // countLines. 116 // countLines.
99 return this->onGetScanlines(storage.get(), countLines, 0); 117 return this->onGetScanlines(storage.get(), countLines, 0);
100 } 118 }
101 119
102 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, 120 virtual SkCodec::Result onGetScanlines(void* dst, int countLines,
103 size_t rowBytes) = 0; 121 size_t rowBytes) = 0;
104 122
105 }; 123 };
106 #endif // SkScanlineDecoder_DEFINED 124 #endif // SkScanlineDecoder_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698