OLD | NEW |
---|---|
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 #include "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 if (!data) { | 72 if (!data) { |
73 return nullptr; | 73 return nullptr; |
74 } | 74 } |
75 return NewFromStream(new SkMemoryStream(data)); | 75 return NewFromStream(new SkMemoryStream(data)); |
76 } | 76 } |
77 | 77 |
78 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) | 78 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) |
79 : fInfo(info) | 79 : fInfo(info) |
80 , fStream(stream) | 80 , fStream(stream) |
81 , fNeedsRewind(false) | 81 , fNeedsRewind(false) |
82 , fIncompleteScanlines(0) | |
82 {} | 83 {} |
83 | 84 |
84 SkCodec::~SkCodec() {} | 85 SkCodec::~SkCodec() {} |
85 | 86 |
86 bool SkCodec::rewindIfNeeded() { | 87 bool SkCodec::rewindIfNeeded() { |
87 // Store the value of fNeedsRewind so we can update it. Next read will | 88 // Store the value of fNeedsRewind so we can update it. Next read will |
88 // require a rewind. | 89 // require a rewind. |
89 const bool needsRewind = fNeedsRewind; | 90 const bool needsRewind = fNeedsRewind; |
90 fNeedsRewind = true; | 91 fNeedsRewind = true; |
91 if (!needsRewind) { | 92 if (!needsRewind) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 // Default options. | 136 // Default options. |
136 Options optsStorage; | 137 Options optsStorage; |
137 if (nullptr == options) { | 138 if (nullptr == options) { |
138 options = &optsStorage; | 139 options = &optsStorage; |
139 } | 140 } |
140 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ct able, ctableCount); | 141 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ct able, ctableCount); |
141 | 142 |
142 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { | 143 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { |
143 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); | 144 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
144 } | 145 } |
146 | |
147 // A return value of kIncompleteInput generally indicates a truncated image stream. | |
scroggo
2015/09/22 18:02:48
generally? Is there an exception?
msarett
2015/09/23 13:22:40
Nope. Removing that word.
| |
148 // In this case, we will fill the provided memory with a default value. | |
149 if (kIncompleteInput == result && 0 != fIncompleteScanlines) { | |
150 void* fillDst = this->getFillDst(pixels, rowBytes, info.height() - fInco mpleteScanlines); | |
151 const SkImageInfo fillInfo = info.makeWH(info.width(), fIncompleteScanli nes); | |
152 const uint32_t fillValue = this->getFillValue(fillInfo); | |
153 SkSwizzler::Fill(fillDst, fillInfo, rowBytes, fillValue, options->fZeroI nitialized); | |
154 fIncompleteScanlines = 0; | |
155 } | |
156 | |
145 return result; | 157 return result; |
146 } | 158 } |
147 | 159 |
148 SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { | 160 SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
149 return this->getPixels(info, pixels, rowBytes, nullptr, nullptr, nullptr); | 161 return this->getPixels(info, pixels, rowBytes, nullptr, nullptr, nullptr); |
150 } | 162 } |
OLD | NEW |