Chromium Code Reviews| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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]; |
| 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 return true; | 88 return true; |
| 89 default: | 89 case FilterOperation::OPACITY: |
| 90 case FilterOperation::COLOR_MATRIX: | |
| 91 case FilterOperation::GRAYSCALE: | |
| 92 case FilterOperation::SEPIA: | |
| 93 case FilterOperation::SATURATE: | |
| 94 case FilterOperation::HUE_ROTATE: | |
| 95 case FilterOperation::INVERT: | |
| 96 case FilterOperation::BRIGHTNESS: | |
| 97 case FilterOperation::CONTRAST: | |
| 98 case FilterOperation::SATURATING_BRIGHTNESS: | |
| 90 break; | 99 break; |
| 91 } | 100 } |
| 92 } | 101 } |
| 93 return false; | 102 return false; |
| 94 } | 103 } |
| 95 | 104 |
| 96 bool FilterOperations::HasFilterThatAffectsOpacity() const { | 105 bool FilterOperations::HasFilterThatAffectsOpacity() const { |
| 97 for (size_t i = 0; i < operations_.size(); ++i) { | 106 for (size_t i = 0; i < operations_.size(); ++i) { |
| 98 const FilterOperation op = operations_[i]; | 107 const FilterOperation op = operations_[i]; |
| 99 switch (op.type()) { | 108 switch (op.type()) { |
| 100 case FilterOperation::OPACITY: | 109 case FilterOperation::OPACITY: |
| 101 case FilterOperation::BLUR: | 110 case FilterOperation::BLUR: |
| 102 case FilterOperation::DROP_SHADOW: | 111 case FilterOperation::DROP_SHADOW: |
| 103 case FilterOperation::ZOOM: | 112 case FilterOperation::ZOOM: |
| 104 return true; | 113 return true; |
| 105 case FilterOperation::COLOR_MATRIX: { | 114 case FilterOperation::COLOR_MATRIX: { |
| 106 const SkScalar* matrix = op.matrix(); | 115 const SkScalar* matrix = op.matrix(); |
| 107 return matrix[15] || matrix[16] || matrix[17] || matrix[18] != 1 || | 116 if (matrix[15] || |
| 108 matrix[19]; | 117 matrix[16] || |
| 118 matrix[17] || | |
| 119 matrix[18] != 1 || | |
| 120 matrix[19]) | |
| 121 return true; | |
|
reveman
2013/08/22 23:14:45
I changed the logic here as it looks like it was w
| |
| 122 break; | |
| 109 } | 123 } |
| 110 default: | 124 case FilterOperation::GRAYSCALE: |
| 125 case FilterOperation::SEPIA: | |
| 126 case FilterOperation::SATURATE: | |
| 127 case FilterOperation::HUE_ROTATE: | |
| 128 case FilterOperation::INVERT: | |
| 129 case FilterOperation::BRIGHTNESS: | |
| 130 case FilterOperation::CONTRAST: | |
| 131 case FilterOperation::SATURATING_BRIGHTNESS: | |
| 111 break; | 132 break; |
| 112 } | 133 } |
| 113 } | 134 } |
| 114 return false; | 135 return false; |
| 115 } | 136 } |
| 116 | 137 |
| 117 FilterOperations FilterOperations::Blend(const FilterOperations& from, | 138 FilterOperations FilterOperations::Blend(const FilterOperations& from, |
| 118 double progress) const { | 139 double progress) const { |
| 119 FilterOperations blended_filters; | 140 FilterOperations blended_filters; |
| 120 if (from.size() == 0) { | 141 if (from.size() == 0) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 148 } | 169 } |
| 149 | 170 |
| 150 scoped_ptr<base::Value> FilterOperations::AsValue() const { | 171 scoped_ptr<base::Value> FilterOperations::AsValue() const { |
| 151 scoped_ptr<base::ListValue> value(new ListValue); | 172 scoped_ptr<base::ListValue> value(new ListValue); |
| 152 for (size_t i = 0; i < operations_.size(); ++i) | 173 for (size_t i = 0; i < operations_.size(); ++i) |
| 153 value->Append(operations_[i].AsValue().release()); | 174 value->Append(operations_[i].AsValue().release()); |
| 154 return value.PassAs<base::Value>(); | 175 return value.PassAs<base::Value>(); |
| 155 } | 176 } |
| 156 | 177 |
| 157 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |