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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "cc/output/filter_operations.h" | 7 #include "cc/output/filter_operations.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 9 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 10 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" | 10 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" |
| 11 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" | 11 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" |
| 12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 SkMatrix MakeScaleMatrix(float x_scale, float y_scale) { | |
|
Stephen White
2016/07/14 22:03:14
BTW, this is SkMatrix::MakeScale().
jbroman
2016/07/14 22:24:06
Done. Don't know how I missed that, it being the v
| |
| 19 SkMatrix matrix; | |
| 20 matrix.setScale(x_scale, y_scale); | |
| 21 return matrix; | |
| 22 } | |
| 23 | |
| 18 TEST(FilterOperationsTest, GetOutsetsBlur) { | 24 TEST(FilterOperationsTest, GetOutsetsBlur) { |
| 19 FilterOperations ops; | 25 FilterOperations ops; |
| 20 ops.Append(FilterOperation::CreateBlurFilter(20)); | 26 ops.Append(FilterOperation::CreateBlurFilter(20)); |
| 21 int top, right, bottom, left; | 27 int top, right, bottom, left; |
| 22 top = right = bottom = left = 0; | 28 top = right = bottom = left = 0; |
| 23 ops.GetOutsets(&top, &right, &bottom, &left); | 29 ops.GetOutsets(&top, &right, &bottom, &left); |
| 24 EXPECT_EQ(60, top); | 30 EXPECT_EQ(60, top); |
| 25 EXPECT_EQ(60, right); | 31 EXPECT_EQ(60, right); |
| 26 EXPECT_EQ(60, bottom); | 32 EXPECT_EQ(60, bottom); |
| 27 EXPECT_EQ(60, left); | 33 EXPECT_EQ(60, left); |
| 28 } | 34 } |
| 29 | 35 |
| 30 TEST(FilterOperationsTest, MapRectBlur) { | 36 TEST(FilterOperationsTest, MapRectBlur) { |
| 31 FilterOperations ops; | 37 FilterOperations ops; |
| 32 ops.Append(FilterOperation::CreateBlurFilter(20)); | 38 ops.Append(FilterOperation::CreateBlurFilter(20)); |
| 33 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), | 39 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), |
| 34 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 40 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 41 EXPECT_EQ(gfx::Rect(-120, -120, 260, 260), | |
| 42 ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 43 EXPECT_EQ(gfx::Rect(-60, -70, 130, 130), | |
| 44 ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 35 } | 45 } |
| 36 | 46 |
| 37 TEST(FilterOperationsTest, MapRectReverseBlur) { | 47 TEST(FilterOperationsTest, MapRectReverseBlur) { |
| 38 FilterOperations ops; | 48 FilterOperations ops; |
| 39 ops.Append(FilterOperation::CreateBlurFilter(20)); | 49 ops.Append(FilterOperation::CreateBlurFilter(20)); |
| 40 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), | 50 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), |
| 41 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 51 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 52 EXPECT_EQ(gfx::Rect(-120, -120, 260, 260), | |
| 53 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 54 EXPECT_EQ( | |
| 55 gfx::Rect(-60, -70, 130, 130), | |
| 56 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 42 } | 57 } |
| 43 | 58 |
| 44 TEST(FilterOperationsTest, GetOutsetsDropShadowReferenceFilter) { | 59 TEST(FilterOperationsTest, GetOutsetsDropShadowReferenceFilter) { |
| 45 // TODO(hendrikw): We need to make outsets for reference filters be in line | 60 // TODO(hendrikw): We need to make outsets for reference filters be in line |
| 46 // with non-reference filters. See crbug.com/523534 | 61 // with non-reference filters. See crbug.com/523534 |
| 47 FilterOperations ops; | 62 FilterOperations ops; |
| 48 ops.Append( | 63 ops.Append( |
| 49 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( | 64 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( |
| 50 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), | 65 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), |
| 51 SkIntToScalar(9), SK_ColorBLACK, | 66 SkIntToScalar(9), SK_ColorBLACK, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 64 TEST(FilterOperationsTest, MapRectDropShadowReferenceFilter) { | 79 TEST(FilterOperationsTest, MapRectDropShadowReferenceFilter) { |
| 65 FilterOperations ops; | 80 FilterOperations ops; |
| 66 ops.Append( | 81 ops.Append( |
| 67 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( | 82 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( |
| 68 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), | 83 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), |
| 69 SkIntToScalar(9), SK_ColorBLACK, | 84 SkIntToScalar(9), SK_ColorBLACK, |
| 70 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, | 85 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, |
| 71 nullptr))); | 86 nullptr))); |
| 72 EXPECT_EQ(gfx::Rect(-9, -19, 34, 64), | 87 EXPECT_EQ(gfx::Rect(-9, -19, 34, 64), |
| 73 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 88 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 89 EXPECT_EQ(gfx::Rect(-18, -38, 68, 128), | |
| 90 ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 91 EXPECT_EQ(gfx::Rect(-9, -45, 34, 64), | |
| 92 ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 74 } | 93 } |
| 75 | 94 |
| 76 TEST(FilterOperationsTest, MapRectReverseDropShadowReferenceFilter) { | 95 TEST(FilterOperationsTest, MapRectReverseDropShadowReferenceFilter) { |
| 77 FilterOperations ops; | 96 FilterOperations ops; |
| 78 ops.Append( | 97 ops.Append( |
| 79 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( | 98 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( |
| 80 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), | 99 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), |
| 81 SkIntToScalar(9), SK_ColorBLACK, | 100 SkIntToScalar(9), SK_ColorBLACK, |
| 82 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, | 101 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, |
| 83 nullptr))); | 102 nullptr))); |
| 84 EXPECT_EQ(gfx::Rect(-15, -35, 34, 64), | 103 EXPECT_EQ(gfx::Rect(-15, -35, 34, 64), |
| 85 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 104 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 105 EXPECT_EQ(gfx::Rect(-30, -70, 68, 128), | |
| 106 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 107 EXPECT_EQ( | |
| 108 gfx::Rect(-15, -29, 34, 64), | |
| 109 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 86 } | 110 } |
| 87 | 111 |
| 88 TEST(FilterOperationsTest, MapRectOffsetReferenceFilter) { | 112 TEST(FilterOperationsTest, MapRectOffsetReferenceFilter) { |
| 89 sk_sp<SkImageFilter> filter = SkOffsetImageFilter::Make(30, 40, nullptr); | 113 sk_sp<SkImageFilter> filter = SkOffsetImageFilter::Make(30, 40, nullptr); |
| 90 FilterOperations ops; | 114 FilterOperations ops; |
| 91 ops.Append(FilterOperation::CreateReferenceFilter(std::move(filter))); | 115 ops.Append(FilterOperation::CreateReferenceFilter(std::move(filter))); |
| 92 EXPECT_EQ(gfx::Rect(30, 40, 10, 10), | 116 EXPECT_EQ(gfx::Rect(30, 40, 10, 10), |
| 93 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 117 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 118 EXPECT_EQ(gfx::Rect(60, 80, 20, 20), | |
| 119 ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 120 EXPECT_EQ(gfx::Rect(30, -50, 10, 10), | |
| 121 ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 94 } | 122 } |
| 95 | 123 |
| 96 TEST(FilterOperationsTest, MapRectReverseOffsetReferenceFilter) { | 124 TEST(FilterOperationsTest, MapRectReverseOffsetReferenceFilter) { |
| 97 sk_sp<SkImageFilter> filter = SkOffsetImageFilter::Make(30, 40, nullptr); | 125 sk_sp<SkImageFilter> filter = SkOffsetImageFilter::Make(30, 40, nullptr); |
| 98 FilterOperations ops; | 126 FilterOperations ops; |
| 99 ops.Append(FilterOperation::CreateReferenceFilter(std::move(filter))); | 127 ops.Append(FilterOperation::CreateReferenceFilter(std::move(filter))); |
| 100 EXPECT_EQ(gfx::Rect(-30, -40, 10, 10), | 128 EXPECT_EQ(gfx::Rect(-30, -40, 10, 10), |
| 101 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 129 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 130 EXPECT_EQ(gfx::Rect(-60, -80, 20, 20), | |
| 131 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 132 EXPECT_EQ( | |
| 133 gfx::Rect(-30, 30, 10, 10), | |
| 134 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 102 } | 135 } |
| 103 | 136 |
| 104 TEST(FilterOperationsTest, MapRectCombineNonCommutative) { | 137 TEST(FilterOperationsTest, MapRectCombineNonCommutative) { |
| 105 // Offsets by 100px in each axis, then scales the resulting image by 2. | 138 // Offsets by 100px in each axis, then scales the resulting image by 2. |
| 106 FilterOperations ops; | 139 FilterOperations ops; |
| 107 ops.Append(FilterOperation::CreateReferenceFilter( | 140 ops.Append(FilterOperation::CreateReferenceFilter( |
| 108 SkOffsetImageFilter::Make(100, 100, nullptr))); | 141 SkOffsetImageFilter::Make(100, 100, nullptr))); |
| 109 SkMatrix scaleMatrix; | 142 SkMatrix scaleMatrix; |
| 110 scaleMatrix.setScale(2, 2); | 143 scaleMatrix.setScale(2, 2); |
| 111 ops.Append( | 144 ops.Append( |
| 112 FilterOperation::CreateReferenceFilter(SkImageFilter::MakeMatrixFilter( | 145 FilterOperation::CreateReferenceFilter(SkImageFilter::MakeMatrixFilter( |
| 113 scaleMatrix, kNone_SkFilterQuality, nullptr))); | 146 scaleMatrix, kNone_SkFilterQuality, nullptr))); |
| 114 | 147 |
| 115 EXPECT_EQ(gfx::Rect(200, 200, 20, 20), | 148 EXPECT_EQ(gfx::Rect(200, 200, 20, 20), |
| 116 ops.MapRect(gfx::Rect(10, 10), SkMatrix::I())); | 149 ops.MapRect(gfx::Rect(10, 10), SkMatrix::I())); |
| 150 EXPECT_EQ(gfx::Rect(400, 400, 40, 40), | |
| 151 ops.MapRect(gfx::Rect(20, 20), MakeScaleMatrix(2, 2))); | |
| 152 EXPECT_EQ(gfx::Rect(200, -220, 20, 20), | |
| 153 ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 117 } | 154 } |
| 118 | 155 |
| 119 TEST(FilterOperationsTest, MapRectReverseCombineNonCommutative) { | 156 TEST(FilterOperationsTest, MapRectReverseCombineNonCommutative) { |
| 120 // Offsets by 100px in each axis, then scales the resulting image by 2. | 157 // Offsets by 100px in each axis, then scales the resulting image by 2. |
| 121 FilterOperations ops; | 158 FilterOperations ops; |
| 122 ops.Append(FilterOperation::CreateReferenceFilter( | 159 ops.Append(FilterOperation::CreateReferenceFilter( |
| 123 SkOffsetImageFilter::Make(100, 100, nullptr))); | 160 SkOffsetImageFilter::Make(100, 100, nullptr))); |
| 124 SkMatrix scaleMatrix; | 161 SkMatrix scaleMatrix; |
| 125 scaleMatrix.setScale(2, 2); | 162 scaleMatrix.setScale(2, 2); |
| 126 ops.Append( | 163 ops.Append( |
| 127 FilterOperation::CreateReferenceFilter(SkImageFilter::MakeMatrixFilter( | 164 FilterOperation::CreateReferenceFilter(SkImageFilter::MakeMatrixFilter( |
| 128 scaleMatrix, kNone_SkFilterQuality, nullptr))); | 165 scaleMatrix, kNone_SkFilterQuality, nullptr))); |
| 129 | 166 |
| 130 EXPECT_EQ(gfx::Rect(10, 10), | 167 EXPECT_EQ(gfx::Rect(10, 10), |
| 131 ops.MapRectReverse(gfx::Rect(200, 200, 20, 20), SkMatrix::I())); | 168 ops.MapRectReverse(gfx::Rect(200, 200, 20, 20), SkMatrix::I())); |
| 169 EXPECT_EQ(gfx::Rect(20, 20), ops.MapRectReverse(gfx::Rect(400, 400, 40, 40), | |
| 170 MakeScaleMatrix(2, 2))); | |
| 171 EXPECT_EQ( | |
| 172 gfx::Rect(0, -10, 10, 10), | |
| 173 ops.MapRectReverse(gfx::Rect(200, -220, 20, 20), MakeScaleMatrix(1, -1))); | |
| 132 } | 174 } |
| 133 | 175 |
| 134 TEST(FilterOperationsTest, GetOutsetsNullReferenceFilter) { | 176 TEST(FilterOperationsTest, GetOutsetsNullReferenceFilter) { |
| 135 FilterOperations ops; | 177 FilterOperations ops; |
| 136 ops.Append(FilterOperation::CreateReferenceFilter(nullptr)); | 178 ops.Append(FilterOperation::CreateReferenceFilter(nullptr)); |
| 137 | 179 |
| 138 int top, right, bottom, left; | 180 int top, right, bottom, left; |
| 139 top = right = bottom = left = 0; | 181 top = right = bottom = left = 0; |
| 140 ops.GetOutsets(&top, &right, &bottom, &left); | 182 ops.GetOutsets(&top, &right, &bottom, &left); |
| 141 EXPECT_EQ(0, top); | 183 EXPECT_EQ(0, top); |
| 142 EXPECT_EQ(0, right); | 184 EXPECT_EQ(0, right); |
| 143 EXPECT_EQ(0, bottom); | 185 EXPECT_EQ(0, bottom); |
| 144 EXPECT_EQ(0, left); | 186 EXPECT_EQ(0, left); |
| 145 } | 187 } |
| 146 | 188 |
| 147 TEST(FilterOperationsTest, MapRectNullReferenceFilter) { | 189 TEST(FilterOperationsTest, MapRectNullReferenceFilter) { |
| 148 FilterOperations ops; | 190 FilterOperations ops; |
| 149 ops.Append(FilterOperation::CreateReferenceFilter(nullptr)); | 191 ops.Append(FilterOperation::CreateReferenceFilter(nullptr)); |
| 150 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), | 192 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), |
| 151 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 193 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 194 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), | |
| 195 ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 196 EXPECT_EQ(gfx::Rect(0, -10, 10, 10), | |
| 197 ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 152 } | 198 } |
| 153 | 199 |
| 154 TEST(FilterOperationsTest, MapRectReverseNullReferenceFilter) { | 200 TEST(FilterOperationsTest, MapRectReverseNullReferenceFilter) { |
| 155 FilterOperations ops; | 201 FilterOperations ops; |
| 156 ops.Append(FilterOperation::CreateReferenceFilter(nullptr)); | 202 ops.Append(FilterOperation::CreateReferenceFilter(nullptr)); |
| 157 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), | 203 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), |
| 158 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 204 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 205 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), | |
| 206 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 207 EXPECT_EQ( | |
| 208 gfx::Rect(0, -10, 10, 10), | |
| 209 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 159 } | 210 } |
| 160 | 211 |
| 161 TEST(FilterOperationsTest, GetOutsetsDropShadow) { | 212 TEST(FilterOperationsTest, GetOutsetsDropShadow) { |
| 162 FilterOperations ops; | 213 FilterOperations ops; |
| 163 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); | 214 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); |
| 164 int top, right, bottom, left; | 215 int top, right, bottom, left; |
| 165 top = right = bottom = left = 0; | 216 top = right = bottom = left = 0; |
| 166 ops.GetOutsets(&top, &right, &bottom, &left); | 217 ops.GetOutsets(&top, &right, &bottom, &left); |
| 167 EXPECT_EQ(52, top); | 218 EXPECT_EQ(52, top); |
| 168 EXPECT_EQ(63, right); | 219 EXPECT_EQ(63, right); |
| 169 EXPECT_EQ(68, bottom); | 220 EXPECT_EQ(68, bottom); |
| 170 EXPECT_EQ(57, left); | 221 EXPECT_EQ(57, left); |
| 171 } | 222 } |
| 172 | 223 |
| 173 TEST(FilterOperationsTest, MapRectDropShadow) { | 224 TEST(FilterOperationsTest, MapRectDropShadow) { |
| 174 FilterOperations ops; | 225 FilterOperations ops; |
| 175 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); | 226 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); |
| 176 EXPECT_EQ(gfx::Rect(-57, -52, 130, 130), | 227 EXPECT_EQ(gfx::Rect(-57, -52, 130, 130), |
| 177 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 228 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 229 EXPECT_EQ(gfx::Rect(-114, -104, 260, 260), | |
| 230 ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 231 EXPECT_EQ(gfx::Rect(-57, -78, 130, 130), | |
| 232 ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 178 } | 233 } |
| 179 | 234 |
| 180 TEST(FilterOperationsTest, MapRectReverseDropShadow) { | 235 TEST(FilterOperationsTest, MapRectReverseDropShadow) { |
| 181 FilterOperations ops; | 236 FilterOperations ops; |
| 182 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); | 237 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); |
| 183 EXPECT_EQ(gfx::Rect(-63, -68, 130, 130), | 238 EXPECT_EQ(gfx::Rect(-63, -68, 130, 130), |
| 184 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 239 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 240 EXPECT_EQ(gfx::Rect(-126, -136, 260, 260), | |
| 241 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2))); | |
| 242 EXPECT_EQ( | |
| 243 gfx::Rect(-63, -62, 130, 130), | |
| 244 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1))); | |
| 185 } | 245 } |
| 186 | 246 |
| 187 TEST(FilterOperationsTest, GetOutsetsDropShadowDoesNotContract) { | 247 TEST(FilterOperationsTest, GetOutsetsDropShadowDoesNotContract) { |
| 188 // Even with a drop-shadow, the original content is still drawn. Thus the | 248 // Even with a drop-shadow, the original content is still drawn. Thus the |
| 189 // content bounds are never contracted due to a drop-shadow. | 249 // content bounds are never contracted due to a drop-shadow. |
| 190 FilterOperations ops; | 250 FilterOperations ops; |
| 191 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0)); | 251 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0)); |
| 192 int top, right, bottom, left; | 252 int top, right, bottom, left; |
| 193 top = right = bottom = left = 0; | 253 top = right = bottom = left = 0; |
| 194 ops.GetOutsets(&top, &right, &bottom, &left); | 254 ops.GetOutsets(&top, &right, &bottom, &left); |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 blended = to.Blend(from, -0.75); | 934 blended = to.Blend(from, -0.75); |
| 875 EXPECT_EQ(to, blended); | 935 EXPECT_EQ(to, blended); |
| 876 blended = to.Blend(from, 0.75); | 936 blended = to.Blend(from, 0.75); |
| 877 EXPECT_EQ(to, blended); | 937 EXPECT_EQ(to, blended); |
| 878 blended = to.Blend(from, 1.5); | 938 blended = to.Blend(from, 1.5); |
| 879 EXPECT_EQ(to, blended); | 939 EXPECT_EQ(to, blended); |
| 880 } | 940 } |
| 881 | 941 |
| 882 } // namespace | 942 } // namespace |
| 883 } // namespace cc | 943 } // namespace cc |
| OLD | NEW |