| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 | 8 |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkErrorInternals.h" |
| 10 #include "SkOrderedReadBuffer.h" | 11 #include "SkOrderedReadBuffer.h" |
| 11 #include "SkStream.h" | 12 #include "SkStream.h" |
| 12 #include "SkTypeface.h" | 13 #include "SkTypeface.h" |
| 13 | 14 |
| 14 SkOrderedReadBuffer::SkOrderedReadBuffer() : INHERITED() { | 15 SkOrderedReadBuffer::SkOrderedReadBuffer() : INHERITED() { |
| 15 fMemoryPtr = NULL; | 16 fMemoryPtr = NULL; |
| 16 | 17 |
| 17 fBitmapStorage = NULL; | 18 fBitmapStorage = NULL; |
| 18 fTFArray = NULL; | 19 fTFArray = NULL; |
| 19 fTFCount = 0; | 20 fTFCount = 0; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if (length > 0) { | 173 if (length > 0) { |
| 173 // Bitmap was encoded. | 174 // Bitmap was encoded. |
| 174 const void* data = this->skip(length); | 175 const void* data = this->skip(length); |
| 175 const int width = this->readInt(); | 176 const int width = this->readInt(); |
| 176 const int height = this->readInt(); | 177 const int height = this->readInt(); |
| 177 if (fBitmapDecoder != NULL && fBitmapDecoder(data, length, bitmap)) { | 178 if (fBitmapDecoder != NULL && fBitmapDecoder(data, length, bitmap)) { |
| 178 SkASSERT(bitmap->width() == width && bitmap->height() == height); | 179 SkASSERT(bitmap->width() == width && bitmap->height() == height); |
| 179 } else { | 180 } else { |
| 180 // This bitmap was encoded when written, but we are unable to decode
, possibly due to | 181 // This bitmap was encoded when written, but we are unable to decode
, possibly due to |
| 181 // not having a decoder. Use a placeholder bitmap. | 182 // not having a decoder. Use a placeholder bitmap. |
| 182 SkDebugf("Could not decode bitmap. Resulting bitmap will be red.\n")
; | 183 SkErrorInternals::SetError(kParseError_SkError, |
| 184 "Could not decode bitmap. Resulting bitma
p will be red."); |
| 183 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 185 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 184 bitmap->allocPixels(); | 186 bitmap->allocPixels(); |
| 185 bitmap->eraseColor(SK_ColorRED); | 187 bitmap->eraseColor(SK_ColorRED); |
| 186 } | 188 } |
| 187 } else { | 189 } else { |
| 188 if (fBitmapStorage) { | 190 if (fBitmapStorage) { |
| 189 const uint32_t index = fReader.readU32(); | 191 const uint32_t index = fReader.readU32(); |
| 190 fReader.readU32(); // bitmap generation ID (see SkOrderedWriteBuffer
::writeBitmap) | 192 fReader.readU32(); // bitmap generation ID (see SkOrderedWriteBuffer
::writeBitmap) |
| 191 *bitmap = *fBitmapStorage->getBitmap(index); | 193 *bitmap = *fBitmapStorage->getBitmap(index); |
| 192 fBitmapStorage->releaseRef(index); | 194 fBitmapStorage->releaseRef(index); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (sizeRecorded != sizeRead) { | 249 if (sizeRecorded != sizeRead) { |
| 248 // we could try to fix up the offset... | 250 // we could try to fix up the offset... |
| 249 sk_throw(); | 251 sk_throw(); |
| 250 } | 252 } |
| 251 } else { | 253 } else { |
| 252 // we must skip the remaining data | 254 // we must skip the remaining data |
| 253 fReader.skip(sizeRecorded); | 255 fReader.skip(sizeRecorded); |
| 254 } | 256 } |
| 255 return obj; | 257 return obj; |
| 256 } | 258 } |
| OLD | NEW |