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 "cc/output/filter_operations.h" | 5 #include "cc/base/filter_operations.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <numeric> | 10 #include <numeric> |
11 | 11 |
12 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "cc/output/filter_operation.h" | 14 #include "cc/base/filter_operation.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 FilterOperations::FilterOperations() {} | 19 FilterOperations::FilterOperations() {} |
20 | 20 |
21 FilterOperations::FilterOperations(const FilterOperations& other) | 21 FilterOperations::FilterOperations(const FilterOperations& other) |
22 : operations_(other.operations_) {} | 22 : operations_(other.operations_) {} |
23 | 23 |
24 FilterOperations::FilterOperations(std::vector<FilterOperation>&& operations) | 24 FilterOperations::FilterOperations(std::vector<FilterOperation>&& operations) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 switch (op.type()) { | 157 switch (op.type()) { |
158 case FilterOperation::OPACITY: | 158 case FilterOperation::OPACITY: |
159 case FilterOperation::BLUR: | 159 case FilterOperation::BLUR: |
160 case FilterOperation::DROP_SHADOW: | 160 case FilterOperation::DROP_SHADOW: |
161 case FilterOperation::ZOOM: | 161 case FilterOperation::ZOOM: |
162 case FilterOperation::REFERENCE: | 162 case FilterOperation::REFERENCE: |
163 case FilterOperation::ALPHA_THRESHOLD: | 163 case FilterOperation::ALPHA_THRESHOLD: |
164 return true; | 164 return true; |
165 case FilterOperation::COLOR_MATRIX: { | 165 case FilterOperation::COLOR_MATRIX: { |
166 const SkScalar* matrix = op.matrix(); | 166 const SkScalar* matrix = op.matrix(); |
167 if (matrix[15] || | 167 if (matrix[15] || matrix[16] || matrix[17] || matrix[18] != 1 || |
168 matrix[16] || | |
169 matrix[17] || | |
170 matrix[18] != 1 || | |
171 matrix[19]) | 168 matrix[19]) |
172 return true; | 169 return true; |
173 break; | 170 break; |
174 } | 171 } |
175 case FilterOperation::GRAYSCALE: | 172 case FilterOperation::GRAYSCALE: |
176 case FilterOperation::SEPIA: | 173 case FilterOperation::SEPIA: |
177 case FilterOperation::SATURATE: | 174 case FilterOperation::SATURATE: |
178 case FilterOperation::HUE_ROTATE: | 175 case FilterOperation::HUE_ROTATE: |
179 case FilterOperation::INVERT: | 176 case FilterOperation::INVERT: |
180 case FilterOperation::BRIGHTNESS: | 177 case FilterOperation::BRIGHTNESS: |
(...skipping 16 matching lines...) Expand all Loading... |
197 FilterOperations FilterOperations::Blend(const FilterOperations& from, | 194 FilterOperations FilterOperations::Blend(const FilterOperations& from, |
198 double progress) const { | 195 double progress) const { |
199 if (HasReferenceFilter() || from.HasReferenceFilter()) | 196 if (HasReferenceFilter() || from.HasReferenceFilter()) |
200 return *this; | 197 return *this; |
201 | 198 |
202 bool from_is_longer = from.size() > size(); | 199 bool from_is_longer = from.size() > size(); |
203 | 200 |
204 size_t shorter_size, longer_size; | 201 size_t shorter_size, longer_size; |
205 if (size() == from.size()) { | 202 if (size() == from.size()) { |
206 shorter_size = longer_size = size(); | 203 shorter_size = longer_size = size(); |
207 } else if (from_is_longer) { | 204 } else if (from_is_longer) { |
208 longer_size = from.size(); | 205 longer_size = from.size(); |
209 shorter_size = size(); | 206 shorter_size = size(); |
210 } else { | 207 } else { |
211 longer_size = size(); | 208 longer_size = size(); |
212 shorter_size = from.size(); | 209 shorter_size = from.size(); |
213 } | 210 } |
214 | 211 |
215 for (size_t i = 0; i < shorter_size; i++) { | 212 for (size_t i = 0; i < shorter_size; i++) { |
216 if (from.at(i).type() != at(i).type()) | 213 if (from.at(i).type() != at(i).type()) |
217 return *this; | 214 return *this; |
(...skipping 29 matching lines...) Expand all Loading... |
247 | 244 |
248 std::string FilterOperations::ToString() const { | 245 std::string FilterOperations::ToString() const { |
249 base::trace_event::TracedValue value; | 246 base::trace_event::TracedValue value; |
250 value.BeginArray("FilterOperations"); | 247 value.BeginArray("FilterOperations"); |
251 AsValueInto(&value); | 248 AsValueInto(&value); |
252 value.EndArray(); | 249 value.EndArray(); |
253 return value.ToString(); | 250 return value.ToString(); |
254 } | 251 } |
255 | 252 |
256 } // namespace cc | 253 } // namespace cc |
OLD | NEW |