Index: cc/output/filter_operation.cc |
diff --git a/cc/output/filter_operation.cc b/cc/output/filter_operation.cc |
index e8a08804632c12c9ba550d6abfcb771464352b66..73e315e96704de9093ef47d52c6c9e9bcea82aaa 100644 |
--- a/cc/output/filter_operation.cc |
+++ b/cc/output/filter_operation.cc |
@@ -21,6 +21,8 @@ bool FilterOperation::operator==(const FilterOperation& other) const { |
drop_shadow_offset_ == other.drop_shadow_offset_ && |
drop_shadow_color_ == other.drop_shadow_color_; |
} |
+ if (type_ == REFERENCE) |
+ return image_filter_.get() == other.image_filter_.get(); |
return amount_ == other.amount_; |
} |
@@ -32,6 +34,7 @@ FilterOperation::FilterOperation(FilterType type, float amount) |
zoom_inset_(0) { |
DCHECK_NE(type_, DROP_SHADOW); |
DCHECK_NE(type_, COLOR_MATRIX); |
+ DCHECK_NE(type_, REFERENCE); |
memset(matrix_, 0, sizeof(matrix_)); |
} |
@@ -68,6 +71,33 @@ FilterOperation::FilterOperation(FilterType type, float amount, int inset) |
memset(matrix_, 0, sizeof(matrix_)); |
} |
+FilterOperation::FilterOperation( |
+ FilterType type, |
+ const skia::RefPtr<SkImageFilter>& image_filter) |
+ : type_(type), |
+ amount_(0), |
+ drop_shadow_offset_(0, 0), |
+ drop_shadow_color_(0), |
+ image_filter_(image_filter), |
+ zoom_inset_(0) { |
+ DCHECK_EQ(type_, REFERENCE); |
+ DCHECK(image_filter.get()); |
+ memset(matrix_, 0, sizeof(matrix_)); |
+} |
+ |
+FilterOperation::FilterOperation(const FilterOperation& other) |
+ : type_(other.type_), |
+ amount_(other.amount_), |
+ drop_shadow_offset_(other.drop_shadow_offset_), |
+ drop_shadow_color_(other.drop_shadow_color_), |
+ image_filter_(other.image_filter_), |
+ zoom_inset_(other.zoom_inset_) { |
+ memcpy(matrix_, other.matrix_, sizeof(matrix_)); |
+} |
+ |
+FilterOperation::~FilterOperation() { |
+} |
+ |
// TODO(ajuma): Define a version of ui::Tween::ValueBetween for floats, and use |
// that instead. |
static float BlendFloats(float from, float to, double progress) { |
@@ -147,6 +177,9 @@ static FilterOperation CreateNoOpFilter(FilterOperation::FilterType type) { |
return FilterOperation::CreateZoomFilter(1.f, 0); |
case FilterOperation::SATURATING_BRIGHTNESS: |
return FilterOperation::CreateSaturatingBrightnessFilter(0.f); |
+ case FilterOperation::REFERENCE: |
+ NOTREACHED(); |
danakj
2013/09/09 22:04:50
Can't create an image filter that does nothing?
ajuma
2013/09/10 21:17:58
Done.
|
+ return FilterOperation::CreateEmptyFilter(); |
} |
NOTREACHED(); |
return FilterOperation::CreateEmptyFilter(); |
@@ -172,6 +205,7 @@ static float ClampAmountForFilterType(float amount, |
case FilterOperation::SATURATING_BRIGHTNESS: |
return amount; |
case FilterOperation::COLOR_MATRIX: |
+ case FilterOperation::REFERENCE: |
NOTREACHED(); |
return amount; |
} |
@@ -188,6 +222,14 @@ FilterOperation FilterOperation::Blend(const FilterOperation* from, |
if (!from && !to) |
return blended_filter; |
+ if ((from && from->type() == FilterOperation::REFERENCE) || |
danakj
2013/09/09 22:04:50
If the two types differ, you might get the |to| or
ajuma
2013/09/10 21:17:58
Done.
|
+ (to && to->type() == FilterOperation::REFERENCE)) { |
+ if (progress > 0.5) |
+ return to ? *to : blended_filter; |
+ else |
+ return from ? *from : blended_filter; |
+ } |
+ |
const FilterOperation& from_op = from ? *from : CreateNoOpFilter(to->type()); |
const FilterOperation& to_op = to ? *to : CreateNoOpFilter(from->type()); |
@@ -250,6 +292,8 @@ scoped_ptr<base::Value> FilterOperation::AsValue() const { |
value->SetDouble("amount", amount_); |
value->SetDouble("inset", zoom_inset_); |
break; |
+ case FilterOperation::REFERENCE: |
+ break; |
danakj
2013/09/09 22:04:50
Is there any data about the filter you can give he
ajuma
2013/09/10 21:17:58
Done.
|
} |
return value.PassAs<base::Value>(); |
} |