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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // TODO: remove this flag, since we're always float (now) | 431 // TODO: remove this flag, since we're always float (now) |
432 info->fFlags |= SkPictInfo::kScalarIsFloat_Flag; | 432 info->fFlags |= SkPictInfo::kScalarIsFloat_Flag; |
433 | 433 |
434 if (8 == sizeof(void*)) { | 434 if (8 == sizeof(void*)) { |
435 info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag; | 435 info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag; |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 // fRecord TODO | 439 // fRecord TODO |
440 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { | 440 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { |
441 SkPicturePlayback* playback = fPlayback.get(); | |
442 | |
443 SkPictInfo info; | 441 SkPictInfo info; |
444 this->createHeader(&info); | 442 this->createHeader(&info); |
445 stream->write(&info, sizeof(info)); | 443 stream->write(&info, sizeof(info)); |
446 if (playback) { | 444 |
| 445 if (NULL != fPlayback.get()) { |
447 stream->writeBool(true); | 446 stream->writeBool(true); |
448 playback->serialize(stream, encoder); | 447 fPlayback->serialize(stream, encoder); |
449 // delete playback if it is a local version (i.e. cons'd up just now) | |
450 if (playback != fPlayback.get()) { | |
451 SkDELETE(playback); | |
452 } | |
453 } else { | 448 } else { |
454 stream->writeBool(false); | 449 stream->writeBool(false); |
455 } | 450 } |
456 } | 451 } |
457 | 452 |
458 // fRecord OK | 453 // fRecord OK |
459 void SkPicture::WriteTagSize(SkWriteBuffer& buffer, uint32_t tag, size_t size) { | 454 void SkPicture::WriteTagSize(SkWriteBuffer& buffer, uint32_t tag, size_t size) { |
460 buffer.writeUInt(tag); | 455 buffer.writeUInt(tag); |
461 buffer.writeUInt(SkToU32(size)); | 456 buffer.writeUInt(SkToU32(size)); |
462 } | 457 } |
463 | 458 |
464 // fRecord OK | 459 // fRecord OK |
465 void SkPicture::WriteTagSize(SkWStream* stream, uint32_t tag, size_t size) { | 460 void SkPicture::WriteTagSize(SkWStream* stream, uint32_t tag, size_t size) { |
466 stream->write32(tag); | 461 stream->write32(tag); |
467 stream->write32(SkToU32(size)); | 462 stream->write32(SkToU32(size)); |
468 } | 463 } |
469 | 464 |
470 // fRecord TODO | 465 // fRecord TODO |
471 void SkPicture::flatten(SkWriteBuffer& buffer) const { | 466 void SkPicture::flatten(SkWriteBuffer& buffer) const { |
472 SkPicturePlayback* playback = fPlayback.get(); | |
473 | |
474 SkPictInfo info; | 467 SkPictInfo info; |
475 this->createHeader(&info); | 468 this->createHeader(&info); |
476 buffer.writeByteArray(&info, sizeof(info)); | 469 buffer.writeByteArray(&info, sizeof(info)); |
477 if (playback) { | 470 |
| 471 if (NULL != fPlayback.get()) { |
478 buffer.writeBool(true); | 472 buffer.writeBool(true); |
479 playback->flatten(buffer); | 473 fPlayback->flatten(buffer); |
480 // delete playback if it is a local version (i.e. cons'd up just now) | |
481 if (playback != fPlayback.get()) { | |
482 SkDELETE(playback); | |
483 } | |
484 } else { | 474 } else { |
485 buffer.writeBool(false); | 475 buffer.writeBool(false); |
486 } | 476 } |
487 } | 477 } |
488 | 478 |
489 #if SK_SUPPORT_GPU | 479 #if SK_SUPPORT_GPU |
490 // fRecord TODO | 480 // fRecord TODO |
491 bool SkPicture::suitableForGpuRasterization(GrContext* context, const char **rea
son) const { | 481 bool SkPicture::suitableForGpuRasterization(GrContext* context, const char **rea
son) const { |
492 if (NULL == fPlayback.get()) { | 482 if (NULL == fPlayback.get()) { |
493 if (NULL != reason) { | 483 if (NULL != reason) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return fUniqueID; | 528 return fUniqueID; |
539 } | 529 } |
540 | 530 |
541 // fRecord OK | 531 // fRecord OK |
542 SkPicture::SkPicture(int width, int height, SkRecord* record) | 532 SkPicture::SkPicture(int width, int height, SkRecord* record) |
543 : fWidth(width) | 533 : fWidth(width) |
544 , fHeight(height) | 534 , fHeight(height) |
545 , fRecord(record) { | 535 , fRecord(record) { |
546 this->needsNewGenID(); | 536 this->needsNewGenID(); |
547 } | 537 } |
OLD | NEW |