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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 {} | 82 {} |
83 | 83 |
84 SkCodec::~SkCodec() {} | 84 SkCodec::~SkCodec() {} |
85 | 85 |
86 SkCodec::RewindState SkCodec::rewindIfNeeded() { | 86 bool SkCodec::rewindIfNeeded() { |
87 // Store the value of fNeedsRewind so we can update it. Next read will | 87 // Store the value of fNeedsRewind so we can update it. Next read will |
88 // require a rewind. | 88 // require a rewind. |
89 const bool needsRewind = fNeedsRewind; | 89 const bool needsRewind = fNeedsRewind; |
90 fNeedsRewind = true; | 90 fNeedsRewind = true; |
91 if (!needsRewind) { | 91 if (!needsRewind) { |
92 return kNoRewindNecessary_RewindState; | 92 return true; |
93 } | 93 } |
94 return fStream->rewind() ? kRewound_RewindState | 94 |
95 : kCouldNotRewind_RewindState; | 95 if (!fStream->rewind()) { |
| 96 return false; |
| 97 } |
| 98 |
| 99 return this->onRewind(); |
96 } | 100 } |
97 | 101 |
98 SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
rowBytes, | 102 SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
rowBytes, |
99 const Options* options, SkPMColor ctable[], i
nt* ctableCount) { | 103 const Options* options, SkPMColor ctable[], i
nt* ctableCount) { |
100 if (kUnknown_SkColorType == info.colorType()) { | 104 if (kUnknown_SkColorType == info.colorType()) { |
101 return kInvalidConversion; | 105 return kInvalidConversion; |
102 } | 106 } |
103 if (NULL == pixels) { | 107 if (NULL == pixels) { |
104 return kInvalidParameters; | 108 return kInvalidParameters; |
105 } | 109 } |
(...skipping 22 matching lines...) Expand all Loading... |
128 | 132 |
129 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { | 133 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { |
130 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); | 134 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
131 } | 135 } |
132 return result; | 136 return result; |
133 } | 137 } |
134 | 138 |
135 SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
rowBytes) { | 139 SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
rowBytes) { |
136 return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL); | 140 return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL); |
137 } | 141 } |
OLD | NEW |