| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 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 | 9 |
| 10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 // Check magic bytes. | 350 // Check magic bytes. |
| 351 SkPictInfo info; | 351 SkPictInfo info; |
| 352 SkASSERT(sizeof(kMagic) == sizeof(info.fMagic)); | 352 SkASSERT(sizeof(kMagic) == sizeof(info.fMagic)); |
| 353 | 353 |
| 354 if (!stream->read(&info.fMagic, sizeof(kMagic))) { | 354 if (!stream->read(&info.fMagic, sizeof(kMagic))) { |
| 355 return false; | 355 return false; |
| 356 } | 356 } |
| 357 | 357 |
| 358 info.fVersion = stream->readU32(); | 358 info.fVersion = stream->readU32(); |
| 359 | 359 info.fCullRect.fLeft = stream->readScalar(); |
| 360 #ifndef V35_COMPATIBILITY_CODE | 360 info.fCullRect.fTop = stream->readScalar(); |
| 361 if (info.fVersion < 35) { | 361 info.fCullRect.fRight = stream->readScalar(); |
| 362 info.fCullRect.fLeft = 0; | 362 info.fCullRect.fBottom = stream->readScalar(); |
| 363 info.fCullRect.fTop = 0; | |
| 364 info.fCullRect.fRight = SkIntToScalar(stream->readU32()); | |
| 365 info.fCullRect.fBottom = SkIntToScalar(stream->readU32()); | |
| 366 } else { | |
| 367 #endif | |
| 368 info.fCullRect.fLeft = stream->readScalar(); | |
| 369 info.fCullRect.fTop = stream->readScalar(); | |
| 370 info.fCullRect.fRight = stream->readScalar(); | |
| 371 info.fCullRect.fBottom = stream->readScalar(); | |
| 372 #ifndef V35_COMPATIBILITY_CODE | |
| 373 } | |
| 374 #endif | |
| 375 | 363 |
| 376 info.fFlags = stream->readU32(); | 364 info.fFlags = stream->readU32(); |
| 377 | 365 |
| 378 if (!IsValidPictInfo(info)) { | 366 if (!IsValidPictInfo(info)) { |
| 379 return false; | 367 return false; |
| 380 } | 368 } |
| 381 | 369 |
| 382 if (pInfo != NULL) { | 370 if (pInfo != NULL) { |
| 383 *pInfo = info; | 371 *pInfo = info; |
| 384 } | 372 } |
| 385 return true; | 373 return true; |
| 386 } | 374 } |
| 387 | 375 |
| 388 bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer* buffer, SkPictInfo* pInfo
) { | 376 bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer* buffer, SkPictInfo* pInfo
) { |
| 389 // Check magic bytes. | 377 // Check magic bytes. |
| 390 SkPictInfo info; | 378 SkPictInfo info; |
| 391 SkASSERT(sizeof(kMagic) == sizeof(info.fMagic)); | 379 SkASSERT(sizeof(kMagic) == sizeof(info.fMagic)); |
| 392 | 380 |
| 393 if (!buffer->readByteArray(&info.fMagic, sizeof(kMagic))) { | 381 if (!buffer->readByteArray(&info.fMagic, sizeof(kMagic))) { |
| 394 return false; | 382 return false; |
| 395 } | 383 } |
| 396 | 384 |
| 397 info.fVersion = buffer->readUInt(); | 385 info.fVersion = buffer->readUInt(); |
| 398 | 386 buffer->readRect(&info.fCullRect); |
| 399 #ifndef V35_COMPATIBILITY_CODE | |
| 400 if (info.fVersion < 35) { | |
| 401 info.fCullRect.fLeft = 0; | |
| 402 info.fCullRect.fTop = 0; | |
| 403 info.fCullRect.fRight = SkIntToScalar(buffer->readUInt()); | |
| 404 info.fCullRect.fBottom = SkIntToScalar(buffer->readUInt()); | |
| 405 } else { | |
| 406 #endif | |
| 407 buffer->readRect(&info.fCullRect); | |
| 408 #ifndef V35_COMPATIBILITY_CODE | |
| 409 } | |
| 410 #endif | |
| 411 | |
| 412 info.fFlags = buffer->readUInt(); | 387 info.fFlags = buffer->readUInt(); |
| 413 | 388 |
| 414 if (!IsValidPictInfo(info)) { | 389 if (!IsValidPictInfo(info)) { |
| 415 return false; | 390 return false; |
| 416 } | 391 } |
| 417 | 392 |
| 418 if (pInfo != NULL) { | 393 if (pInfo != NULL) { |
| 419 *pInfo = info; | 394 *pInfo = info; |
| 420 } | 395 } |
| 421 return true; | 396 return true; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 499 |
| 525 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, | 500 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, |
| 526 SkBBoxHierarchy* bbh) | 501 SkBBoxHierarchy* bbh) |
| 527 : fUniqueID(next_picture_generation_id()) | 502 : fUniqueID(next_picture_generation_id()) |
| 528 , fCullRect(cullRect) | 503 , fCullRect(cullRect) |
| 529 , fRecord(SkRef(record)) | 504 , fRecord(SkRef(record)) |
| 530 , fBBH(SkSafeRef(bbh)) | 505 , fBBH(SkSafeRef(bbh)) |
| 531 , fDrawablePicts(drawablePicts) // take ownership | 506 , fDrawablePicts(drawablePicts) // take ownership |
| 532 , fAnalysis(*fRecord) | 507 , fAnalysis(*fRecord) |
| 533 {} | 508 {} |
| OLD | NEW |