OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "cc/output/filter_operations.h" | 7 #include "cc/output/filter_operations.h" |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/output/filter_operation.h" | 10 #include "cc/output/filter_operation.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 *right += spread + op.drop_shadow_offset().x(); | 73 *right += spread + op.drop_shadow_offset().x(); |
74 *bottom += spread + op.drop_shadow_offset().y(); | 74 *bottom += spread + op.drop_shadow_offset().y(); |
75 *left += spread - op.drop_shadow_offset().x(); | 75 *left += spread - op.drop_shadow_offset().x(); |
76 } | 76 } |
77 } | 77 } |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 bool FilterOperations::HasFilterThatMovesPixels() const { | 81 bool FilterOperations::HasFilterThatMovesPixels() const { |
82 for (size_t i = 0; i < operations_.size(); ++i) { | 82 for (size_t i = 0; i < operations_.size(); ++i) { |
83 const FilterOperation op = operations_[i]; | 83 const FilterOperation op = operations_[i]; |
danakj
2013/09/09 22:04:50
hmm, I think we meant const& here btw..
ajuma
2013/09/10 21:17:58
Done.
| |
84 switch (op.type()) { | 84 switch (op.type()) { |
85 case FilterOperation::BLUR: | 85 case FilterOperation::BLUR: |
86 case FilterOperation::DROP_SHADOW: | 86 case FilterOperation::DROP_SHADOW: |
87 case FilterOperation::ZOOM: | 87 case FilterOperation::ZOOM: |
88 case FilterOperation::REFERENCE: | |
danakj
2013/09/09 22:04:50
Should we DCHECK() that this is not called with RE
ajuma
2013/09/10 21:17:58
Done. Also added a DCHECK to GetOutsets for the sa
| |
88 return true; | 89 return true; |
89 case FilterOperation::OPACITY: | 90 case FilterOperation::OPACITY: |
90 case FilterOperation::COLOR_MATRIX: | 91 case FilterOperation::COLOR_MATRIX: |
91 case FilterOperation::GRAYSCALE: | 92 case FilterOperation::GRAYSCALE: |
92 case FilterOperation::SEPIA: | 93 case FilterOperation::SEPIA: |
93 case FilterOperation::SATURATE: | 94 case FilterOperation::SATURATE: |
94 case FilterOperation::HUE_ROTATE: | 95 case FilterOperation::HUE_ROTATE: |
95 case FilterOperation::INVERT: | 96 case FilterOperation::INVERT: |
96 case FilterOperation::BRIGHTNESS: | 97 case FilterOperation::BRIGHTNESS: |
97 case FilterOperation::CONTRAST: | 98 case FilterOperation::CONTRAST: |
98 case FilterOperation::SATURATING_BRIGHTNESS: | 99 case FilterOperation::SATURATING_BRIGHTNESS: |
99 break; | 100 break; |
100 } | 101 } |
101 } | 102 } |
102 return false; | 103 return false; |
103 } | 104 } |
104 | 105 |
105 bool FilterOperations::HasFilterThatAffectsOpacity() const { | 106 bool FilterOperations::HasFilterThatAffectsOpacity() const { |
106 for (size_t i = 0; i < operations_.size(); ++i) { | 107 for (size_t i = 0; i < operations_.size(); ++i) { |
107 const FilterOperation op = operations_[i]; | 108 const FilterOperation op = operations_[i]; |
danakj
2013/09/09 22:04:50
hmm, I think we meant const& here btw..
ajuma
2013/09/10 21:17:58
Done.
| |
108 switch (op.type()) { | 109 switch (op.type()) { |
109 case FilterOperation::OPACITY: | 110 case FilterOperation::OPACITY: |
110 case FilterOperation::BLUR: | 111 case FilterOperation::BLUR: |
111 case FilterOperation::DROP_SHADOW: | 112 case FilterOperation::DROP_SHADOW: |
112 case FilterOperation::ZOOM: | 113 case FilterOperation::ZOOM: |
114 case FilterOperation::REFERENCE: | |
113 return true; | 115 return true; |
114 case FilterOperation::COLOR_MATRIX: { | 116 case FilterOperation::COLOR_MATRIX: { |
115 const SkScalar* matrix = op.matrix(); | 117 const SkScalar* matrix = op.matrix(); |
116 if (matrix[15] || | 118 if (matrix[15] || |
117 matrix[16] || | 119 matrix[16] || |
118 matrix[17] || | 120 matrix[17] || |
119 matrix[18] != 1 || | 121 matrix[18] != 1 || |
120 matrix[19]) | 122 matrix[19]) |
121 return true; | 123 return true; |
122 break; | 124 break; |
123 } | 125 } |
124 case FilterOperation::GRAYSCALE: | 126 case FilterOperation::GRAYSCALE: |
125 case FilterOperation::SEPIA: | 127 case FilterOperation::SEPIA: |
126 case FilterOperation::SATURATE: | 128 case FilterOperation::SATURATE: |
127 case FilterOperation::HUE_ROTATE: | 129 case FilterOperation::HUE_ROTATE: |
128 case FilterOperation::INVERT: | 130 case FilterOperation::INVERT: |
129 case FilterOperation::BRIGHTNESS: | 131 case FilterOperation::BRIGHTNESS: |
130 case FilterOperation::CONTRAST: | 132 case FilterOperation::CONTRAST: |
131 case FilterOperation::SATURATING_BRIGHTNESS: | 133 case FilterOperation::SATURATING_BRIGHTNESS: |
132 break; | 134 break; |
133 } | 135 } |
134 } | 136 } |
135 return false; | 137 return false; |
136 } | 138 } |
137 | 139 |
140 bool FilterOperations::HasReferenceFilter() const { | |
141 for (size_t i = 0; i < operations_.size(); ++i) { | |
142 if (operations_[i].type() == FilterOperation::REFERENCE) | |
143 return true; | |
144 } | |
145 return false; | |
146 } | |
147 | |
138 FilterOperations FilterOperations::Blend(const FilterOperations& from, | 148 FilterOperations FilterOperations::Blend(const FilterOperations& from, |
139 double progress) const { | 149 double progress) const { |
140 FilterOperations blended_filters; | 150 FilterOperations blended_filters; |
141 if (from.size() == 0) { | 151 if (from.size() == 0) { |
142 for (size_t i = 0; i < size(); i++) | 152 for (size_t i = 0; i < size(); i++) |
143 blended_filters.Append(FilterOperation::Blend(NULL, &at(i), progress)); | 153 blended_filters.Append(FilterOperation::Blend(NULL, &at(i), progress)); |
144 return blended_filters; | 154 return blended_filters; |
145 } | 155 } |
146 | 156 |
147 if (size() == 0) { | 157 if (size() == 0) { |
(...skipping 21 matching lines...) Expand all Loading... | |
169 } | 179 } |
170 | 180 |
171 scoped_ptr<base::Value> FilterOperations::AsValue() const { | 181 scoped_ptr<base::Value> FilterOperations::AsValue() const { |
172 scoped_ptr<base::ListValue> value(new ListValue); | 182 scoped_ptr<base::ListValue> value(new ListValue); |
173 for (size_t i = 0; i < operations_.size(); ++i) | 183 for (size_t i = 0; i < operations_.size(); ++i) |
174 value->Append(operations_[i].AsValue().release()); | 184 value->Append(operations_[i].AsValue().release()); |
175 return value.PassAs<base::Value>(); | 185 return value.PassAs<base::Value>(); |
176 } | 186 } |
177 | 187 |
178 } // namespace cc | 188 } // namespace cc |
OLD | NEW |