Chromium Code Reviews| Index: cc/output/filter_operations.cc |
| diff --git a/cc/output/filter_operations.cc b/cc/output/filter_operations.cc |
| index 92ddd684777ef9e71fab6cbd1a3805a0f0db3dd9..87634148f7b6a9ab16f4e03ba66159420aed7cb7 100644 |
| --- a/cc/output/filter_operations.cc |
| +++ b/cc/output/filter_operations.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <algorithm> |
|
ajuma
2013/11/12 21:39:42
Can this be removed?
avallee
2013/11/12 21:42:16
Sorry, missed that before. Done.
|
| #include <cmath> |
| #include "cc/output/filter_operations.h" |
| @@ -154,34 +155,43 @@ bool FilterOperations::HasReferenceFilter() const { |
| FilterOperations FilterOperations::Blend(const FilterOperations& from, |
| double progress) const { |
| - FilterOperations blended_filters; |
| - if (from.size() == 0) { |
| - for (size_t i = 0; i < size(); i++) |
| - blended_filters.Append(FilterOperation::Blend(NULL, &at(i), progress)); |
| - return blended_filters; |
| - } |
| + if (HasReferenceFilter() || from.HasReferenceFilter()) |
| + return *this; |
| - if (size() == 0) { |
| - for (size_t i = 0; i < from.size(); i++) { |
| - blended_filters.Append( |
| - FilterOperation::Blend(&from.at(i), NULL, progress)); |
| - } |
| - return blended_filters; |
| + bool from_is_longer = from.size() > size(); |
| + |
| + size_t shorter_size, longer_size; |
| + if (size() == from.size()) { |
| + shorter_size = longer_size = size(); |
| + } else if (from_is_longer) { |
| + longer_size = from.size(); |
| + shorter_size = size(); |
| + } else { |
| + longer_size = size(); |
| + shorter_size = from.size(); |
| } |
| - if (from.size() != size()) |
| - return *this; |
| - |
| - for (size_t i = 0; i < size(); i++) { |
| + for (size_t i = 0; i < shorter_size; i++) { |
| if (from.at(i).type() != at(i).type()) |
| return *this; |
| } |
| - for (size_t i = 0; i < size(); i++) { |
| + FilterOperations blended_filters; |
| + for (size_t i = 0; i < shorter_size; i++) { |
| blended_filters.Append( |
| FilterOperation::Blend(&from.at(i), &at(i), progress)); |
| } |
| + if (from_is_longer) { |
| + for (size_t i = shorter_size; i < longer_size; i++) { |
| + blended_filters.Append( |
| + FilterOperation::Blend(&from.at(i), NULL, progress)); |
| + } |
| + } else { |
| + for (size_t i = shorter_size; i < longer_size; i++) |
| + blended_filters.Append(FilterOperation::Blend(NULL, &at(i), progress)); |
| + } |
| + |
| return blended_filters; |
| } |