| 609 | } |
| 610 | |
| 611 | void OpRcPtrVec::optimize(OptimizationFlags oFlags) |
| 612 | { |
| 613 | if (m_ops.empty()) |
| 614 | { |
| 615 | return; |
| 616 | } |
| 617 | |
| 618 | if (IsDebugLoggingEnabled()) |
| 619 | { |
| 620 | std::ostringstream oss; |
| 621 | oss << std::endl |
| 622 | << "**" << std::endl |
| 623 | << "Optimizing Op Vec..." << std::endl |
| 624 | << SerializeOpVec(*this, 4) << std::endl; |
| 625 | |
| 626 | LogDebug(oss.str()); |
| 627 | } |
| 628 | |
| 629 | const auto originalSize = size(); |
| 630 | |
| 631 | // NoOpType can be removed (facilitates conversion to a CPU/GPUProcessor). |
| 632 | const int total_nooptype = RemoveNoOpTypes(*this); |
| 633 | |
| 634 | if (oFlags == OPTIMIZATION_NONE) |
| 635 | { |
| 636 | if (IsDebugLoggingEnabled()) |
| 637 | { |
| 638 | OpRcPtrVec::size_type finalSize = size(); |
| 639 | |
| 640 | std::ostringstream os; |
| 641 | os << "**" << std::endl; |
| 642 | os << "Optimized "; |
| 643 | os << originalSize << "->" << finalSize << ", 1 pass, "; |
| 644 | os << total_nooptype << " no-op types removed\n"; |
| 645 | os << SerializeOpVec(*this, 4); |
| 646 | LogDebug(os.str()); |
| 647 | } |
| 648 | |
| 649 | return; |
| 650 | } |
| 651 | |
| 652 | // Keep dynamic ops using their default values. Remove the ability to modify |
| 653 | // them dynamically. |
| 654 | const auto removeDynamic = HasFlag(oFlags, OPTIMIZATION_NO_DYNAMIC_PROPERTIES); |
| 655 | if (removeDynamic) |
| 656 | { |
| 657 | RemoveDynamicProperties(*this); |
| 658 | } |
| 659 | |
| 660 | // As the input and output bit-depths represent the color processing |
| 661 | // request and they may be altered by the following optimizations, |
| 662 | // preserve their values. |
| 663 | |
| 664 | int total_noops = 0; |
| 665 | int total_replacedops = 0; |
| 666 | int total_identityops = 0; |
| 667 | int total_inverseops = 0; |
| 668 | int total_combines = 0; |