Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: cc/output/filter_operations.cc

Issue 64123005: Update filter blending to match spec draft. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698