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..afea8eb714a05aebd5ed33aa9fcee362e3361a8c 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> |
| #include <cmath> |
| #include "cc/output/filter_operations.h" |
| @@ -154,6 +155,9 @@ bool FilterOperations::HasReferenceFilter() const { |
| FilterOperations FilterOperations::Blend(const FilterOperations& from, |
| double progress) const { |
| + if (HasReferenceFilter() || from.HasReferenceFilter()) |
| + return *this; |
| + |
| FilterOperations blended_filters; |
| if (from.size() == 0) { |
| for (size_t i = 0; i < size(); i++) |
| @@ -170,7 +174,7 @@ FilterOperations FilterOperations::Blend(const FilterOperations& from, |
| } |
| if (from.size() != size()) |
| - return *this; |
| + return BlendRaggedOperations(from, progress); |
|
ajuma
2013/11/11 18:39:41
Could we merge the logic of blending different siz
avallee
2013/11/12 20:18:09
Done.
|
| for (size_t i = 0; i < size(); i++) { |
| if (from.at(i).type() != at(i).type()) |
| @@ -192,4 +196,36 @@ scoped_ptr<base::Value> FilterOperations::AsValue() const { |
| return value.PassAs<base::Value>(); |
| } |
| +FilterOperations FilterOperations::BlendRaggedOperations( |
| + const FilterOperations& from, |
| + double progress) const { |
| + size_t shorter_size = std::min(from.size(), size()); |
| + for (size_t i = 0; i < shorter_size; ++i) { |
| + if (from.at(i).type() != at(i).type()) |
| + return *this; |
| + } |
| + |
| + FilterOperations blended_filters; |
| + for (size_t i = 0; i < shorter_size; ++i) { |
| + blended_filters.Append( |
| + FilterOperation::Blend(&from.at(i), &at(i), progress)); |
| + } |
| + |
| + bool from_is_longer = size() < from.size(); |
| + |
| + if (from_is_longer) { |
| + for (size_t i = shorter_size; i < from.size(); ++i) { |
| + blended_filters.Append( |
| + FilterOperation::Blend(&from.at(i), NULL, progress)); |
| + } |
| + } else { |
| + for (size_t i = shorter_size; i < size(); ++i) { |
| + blended_filters.Append( |
| + FilterOperation::Blend(NULL, &at(i), progress)); |
| + } |
| + } |
| + |
| + return blended_filters; |
| +} |
| + |
| } // namespace cc |