OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkImageRef.h" | 8 #include "SkImageRef.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 /////////////////////////////////////////////////////////////////////////////// | 169 /////////////////////////////////////////////////////////////////////////////// |
170 | 170 |
171 SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) | 171 SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) |
172 : INHERITED(buffer, mutex), fErrorInDecoding(false) { | 172 : INHERITED(buffer, mutex), fErrorInDecoding(false) { |
173 fConfig = (SkBitmap::Config)buffer.readUInt(); | 173 fConfig = (SkBitmap::Config)buffer.readUInt(); |
174 fSampleSize = buffer.readInt(); | 174 fSampleSize = buffer.readInt(); |
175 fDoDither = buffer.readBool(); | 175 fDoDither = buffer.readBool(); |
176 | 176 |
177 size_t length = buffer.getArrayCount(); | 177 size_t length = buffer.getArrayCount(); |
178 fStream = SkNEW_ARGS(SkMemoryStream, (length)); | 178 fStream = SkNEW_ARGS(SkMemoryStream, (length)); |
179 buffer.readByteArray((void*)fStream->getMemoryBase()); | 179 buffer.readByteArray((void*)fStream->getMemoryBase(), length); |
180 | 180 |
181 fPrev = fNext = NULL; | 181 fPrev = fNext = NULL; |
182 fFactory = NULL; | 182 fFactory = NULL; |
183 } | 183 } |
184 | 184 |
185 void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const { | 185 void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const { |
186 this->INHERITED::flatten(buffer); | 186 this->INHERITED::flatten(buffer); |
187 | 187 |
188 buffer.writeUInt(fConfig); | 188 buffer.writeUInt(fConfig); |
189 buffer.writeInt(fSampleSize); | 189 buffer.writeInt(fSampleSize); |
190 buffer.writeBool(fDoDither); | 190 buffer.writeBool(fDoDither); |
191 // FIXME: Consider moving this logic should go into writeStream itself. | 191 // FIXME: Consider moving this logic should go into writeStream itself. |
192 // writeStream currently has no other callers, so this may be fine for | 192 // writeStream currently has no other callers, so this may be fine for |
193 // now. | 193 // now. |
194 if (!fStream->rewind()) { | 194 if (!fStream->rewind()) { |
195 SkDEBUGF(("Failed to rewind SkImageRef stream!")); | 195 SkDEBUGF(("Failed to rewind SkImageRef stream!")); |
196 buffer.write32(0); | 196 buffer.write32(0); |
197 } else { | 197 } else { |
198 // FIXME: Handle getLength properly here. Perhaps this class should | 198 // FIXME: Handle getLength properly here. Perhaps this class should |
199 // take an SkStreamAsset. | 199 // take an SkStreamAsset. |
200 buffer.writeStream(fStream, fStream->getLength()); | 200 buffer.writeStream(fStream, fStream->getLength()); |
201 } | 201 } |
202 } | 202 } |
OLD | NEW |