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 "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
9 #include "SkTSearch.h" | 9 #include "SkTSearch.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 convert_command_to_noop(writer, saveLayerInfo.fOffset); | 405 convert_command_to_noop(writer, saveLayerInfo.fOffset); |
406 uint32_t* ptr = writer->peek32(dbmInfo.fOffset+dbmPaintOffset); | 406 uint32_t* ptr = writer->peek32(dbmInfo.fOffset+dbmPaintOffset); |
407 SkASSERT(dbmPaintId == *ptr); | 407 SkASSERT(dbmPaintId == *ptr); |
408 *ptr = data->index(); | 408 *ptr = data->index(); |
409 return true; | 409 return true; |
410 } | 410 } |
411 | 411 |
412 /* | 412 /* |
413 * Restore has just been called (but not recorded), look back at the | 413 * Restore has just been called (but not recorded), look back at the |
414 * matching save* and see if we are in the configuration: | 414 * matching save* and see if we are in the configuration: |
415 * SAVE_LAYER | 415 * SAVE_LAYER (with NULL == bounds) |
416 * SAVE | 416 * SAVE |
417 * CLIP_RECT | 417 * CLIP_RECT |
418 * DRAW_BITMAP|DRAW_BITMAP_MATRIX|DRAW_BITMAP_NINE|DRAW_BITMAP_RECT_TO_R
ECT | 418 * DRAW_BITMAP|DRAW_BITMAP_MATRIX|DRAW_BITMAP_NINE|DRAW_BITMAP_RECT_TO_R
ECT |
419 * RESTORE | 419 * RESTORE |
420 * RESTORE | 420 * RESTORE |
421 * where the saveLayer's color can be moved into the drawBitmap*'s paint | 421 * where the saveLayer's color can be moved into the drawBitmap*'s paint |
422 */ | 422 */ |
423 static bool remove_save_layer2(SkWriter32* writer, int32_t offset, | 423 static bool remove_save_layer2(SkWriter32* writer, int32_t offset, |
424 SkPaintDictionary* paintDict) { | 424 SkPaintDictionary* paintDict) { |
425 | 425 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 if (fRestoreOffsetStack.count() == 0) { | 558 if (fRestoreOffsetStack.count() == 0) { |
559 return; | 559 return; |
560 } | 560 } |
561 | 561 |
562 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { | 562 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { |
563 fFirstSavedLayerIndex = kNoSavedLayerIndex; | 563 fFirstSavedLayerIndex = kNoSavedLayerIndex; |
564 } | 564 } |
565 | 565 |
566 uint32_t initialOffset, size; | 566 uint32_t initialOffset, size; |
567 size_t opt; | 567 size_t opt; |
568 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) { | 568 if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag))
{ |
569 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.top()
, &fPaints)) { | 569 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) { |
570 // Some optimization fired so don't add the RESTORE | 570 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t
op(), &fPaints)) { |
571 size = 0; | 571 // Some optimization fired so don't add the RESTORE |
572 initialOffset = fWriter.size(); | 572 size = 0; |
573 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType, | 573 initialOffset = fWriter.size(); |
574 fStateTree, fBoundingHierarchy); | 574 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType, |
575 break; | 575 fStateTree, fBoundingHierarchy); |
| 576 break; |
| 577 } |
576 } | 578 } |
577 } | 579 } |
578 | 580 |
579 if (SK_ARRAY_COUNT(gPictureRecordOpts) == opt) { | 581 if ((fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag) || |
| 582 SK_ARRAY_COUNT(gPictureRecordOpts) == opt) { |
580 // No optimization fired so add the RESTORE | 583 // No optimization fired so add the RESTORE |
581 fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.size
()); | 584 fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.size
()); |
582 size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code | 585 size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code |
583 initialOffset = this->addDraw(RESTORE, &size); | 586 initialOffset = this->addDraw(RESTORE, &size); |
584 } | 587 } |
585 | 588 |
586 fRestoreOffsetStack.pop(); | 589 fRestoreOffsetStack.pop(); |
587 | 590 |
588 validate(initialOffset, size); | 591 validate(initialOffset, size); |
589 return this->INHERITED::restore(); | 592 return this->INHERITED::restore(); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 void SkPictureRecord::validateRegions() const { | 1450 void SkPictureRecord::validateRegions() const { |
1448 int count = fRegions.count(); | 1451 int count = fRegions.count(); |
1449 SkASSERT((unsigned) count < 0x1000); | 1452 SkASSERT((unsigned) count < 0x1000); |
1450 for (int index = 0; index < count; index++) { | 1453 for (int index = 0; index < count; index++) { |
1451 const SkFlatData* region = fRegions[index]; | 1454 const SkFlatData* region = fRegions[index]; |
1452 SkASSERT(region); | 1455 SkASSERT(region); |
1453 // region->validate(); | 1456 // region->validate(); |
1454 } | 1457 } |
1455 } | 1458 } |
1456 #endif | 1459 #endif |
OLD | NEW |