| 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/output/filter_operations.h" |
| 6 #include "skia/ext/refptr.h" | 6 #include "skia/ext/refptr.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 8 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 EXPECT_EQ(expected, blended); | 153 EXPECT_EQ(expected, blended); |
| 154 | 154 |
| 155 blended = FilterOperation::Blend(&from, &to, 1.8); | 155 blended = FilterOperation::Blend(&from, &to, 1.8); |
| 156 expected = FilterOperation::CreateGrayscaleFilter(1.f); | 156 expected = FilterOperation::CreateGrayscaleFilter(1.f); |
| 157 EXPECT_EQ(expected, blended); | 157 EXPECT_EQ(expected, blended); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST(FilterOperationsTest, BlendGrayscaleWithNull) { | 160 TEST(FilterOperationsTest, BlendGrayscaleWithNull) { |
| 161 FilterOperation filter = FilterOperation::CreateGrayscaleFilter(1.f); | 161 FilterOperation filter = FilterOperation::CreateGrayscaleFilter(1.f); |
| 162 | 162 |
| 163 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 163 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 164 FilterOperation expected = FilterOperation::CreateGrayscaleFilter(0.75f); | 164 FilterOperation expected = FilterOperation::CreateGrayscaleFilter(0.75f); |
| 165 EXPECT_EQ(expected, blended); | 165 EXPECT_EQ(expected, blended); |
| 166 | 166 |
| 167 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 167 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 168 expected = FilterOperation::CreateGrayscaleFilter(0.25f); | 168 expected = FilterOperation::CreateGrayscaleFilter(0.25f); |
| 169 EXPECT_EQ(expected, blended); | 169 EXPECT_EQ(expected, blended); |
| 170 } | 170 } |
| 171 | 171 |
| 172 TEST(FilterOperationsTest, BlendSepiaFilters) { | 172 TEST(FilterOperationsTest, BlendSepiaFilters) { |
| 173 FilterOperation from = FilterOperation::CreateSepiaFilter(0.25f); | 173 FilterOperation from = FilterOperation::CreateSepiaFilter(0.25f); |
| 174 FilterOperation to = FilterOperation::CreateSepiaFilter(0.75f); | 174 FilterOperation to = FilterOperation::CreateSepiaFilter(0.75f); |
| 175 | 175 |
| 176 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 176 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 177 FilterOperation expected = FilterOperation::CreateSepiaFilter(0.f); | 177 FilterOperation expected = FilterOperation::CreateSepiaFilter(0.f); |
| 178 EXPECT_EQ(expected, blended); | 178 EXPECT_EQ(expected, blended); |
| 179 | 179 |
| 180 blended = FilterOperation::Blend(&from, &to, 0.75); | 180 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 181 expected = FilterOperation::CreateSepiaFilter(0.625f); | 181 expected = FilterOperation::CreateSepiaFilter(0.625f); |
| 182 EXPECT_EQ(expected, blended); | 182 EXPECT_EQ(expected, blended); |
| 183 | 183 |
| 184 blended = FilterOperation::Blend(&from, &to, 1.8); | 184 blended = FilterOperation::Blend(&from, &to, 1.8); |
| 185 expected = FilterOperation::CreateSepiaFilter(1.f); | 185 expected = FilterOperation::CreateSepiaFilter(1.f); |
| 186 EXPECT_EQ(expected, blended); | 186 EXPECT_EQ(expected, blended); |
| 187 } | 187 } |
| 188 | 188 |
| 189 TEST(FilterOperationsTest, BlendSepiaWithNull) { | 189 TEST(FilterOperationsTest, BlendSepiaWithNull) { |
| 190 FilterOperation filter = FilterOperation::CreateSepiaFilter(1.f); | 190 FilterOperation filter = FilterOperation::CreateSepiaFilter(1.f); |
| 191 | 191 |
| 192 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 192 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 193 FilterOperation expected = FilterOperation::CreateSepiaFilter(0.75f); | 193 FilterOperation expected = FilterOperation::CreateSepiaFilter(0.75f); |
| 194 EXPECT_EQ(expected, blended); | 194 EXPECT_EQ(expected, blended); |
| 195 | 195 |
| 196 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 196 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 197 expected = FilterOperation::CreateSepiaFilter(0.25f); | 197 expected = FilterOperation::CreateSepiaFilter(0.25f); |
| 198 EXPECT_EQ(expected, blended); | 198 EXPECT_EQ(expected, blended); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TEST(FilterOperationsTest, BlendSaturateFilters) { | 201 TEST(FilterOperationsTest, BlendSaturateFilters) { |
| 202 FilterOperation from = FilterOperation::CreateSaturateFilter(0.25f); | 202 FilterOperation from = FilterOperation::CreateSaturateFilter(0.25f); |
| 203 FilterOperation to = FilterOperation::CreateSaturateFilter(0.75f); | 203 FilterOperation to = FilterOperation::CreateSaturateFilter(0.75f); |
| 204 | 204 |
| 205 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 205 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 206 FilterOperation expected = FilterOperation::CreateSaturateFilter(0.f); | 206 FilterOperation expected = FilterOperation::CreateSaturateFilter(0.f); |
| 207 EXPECT_EQ(expected, blended); | 207 EXPECT_EQ(expected, blended); |
| 208 | 208 |
| 209 blended = FilterOperation::Blend(&from, &to, 0.75); | 209 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 210 expected = FilterOperation::CreateSaturateFilter(0.625f); | 210 expected = FilterOperation::CreateSaturateFilter(0.625f); |
| 211 EXPECT_EQ(expected, blended); | 211 EXPECT_EQ(expected, blended); |
| 212 | 212 |
| 213 blended = FilterOperation::Blend(&from, &to, 2.0); | 213 blended = FilterOperation::Blend(&from, &to, 2.0); |
| 214 expected = FilterOperation::CreateSaturateFilter(1.25f); | 214 expected = FilterOperation::CreateSaturateFilter(1.25f); |
| 215 EXPECT_EQ(expected, blended); | 215 EXPECT_EQ(expected, blended); |
| 216 } | 216 } |
| 217 | 217 |
| 218 TEST(FilterOperationsTest, BlendSaturateWithNull) { | 218 TEST(FilterOperationsTest, BlendSaturateWithNull) { |
| 219 FilterOperation filter = FilterOperation::CreateSaturateFilter(0.f); | 219 FilterOperation filter = FilterOperation::CreateSaturateFilter(0.f); |
| 220 | 220 |
| 221 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 221 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 222 FilterOperation expected = FilterOperation::CreateSaturateFilter(0.25f); | 222 FilterOperation expected = FilterOperation::CreateSaturateFilter(0.25f); |
| 223 EXPECT_EQ(expected, blended); | 223 EXPECT_EQ(expected, blended); |
| 224 | 224 |
| 225 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 225 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 226 expected = FilterOperation::CreateSaturateFilter(0.75f); | 226 expected = FilterOperation::CreateSaturateFilter(0.75f); |
| 227 EXPECT_EQ(expected, blended); | 227 EXPECT_EQ(expected, blended); |
| 228 } | 228 } |
| 229 | 229 |
| 230 TEST(FilterOperationsTest, BlendHueRotateFilters) { | 230 TEST(FilterOperationsTest, BlendHueRotateFilters) { |
| 231 FilterOperation from = FilterOperation::CreateHueRotateFilter(3.f); | 231 FilterOperation from = FilterOperation::CreateHueRotateFilter(3.f); |
| 232 FilterOperation to = FilterOperation::CreateHueRotateFilter(7.f); | 232 FilterOperation to = FilterOperation::CreateHueRotateFilter(7.f); |
| 233 | 233 |
| 234 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 234 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 235 FilterOperation expected = FilterOperation::CreateHueRotateFilter(0.f); | 235 FilterOperation expected = FilterOperation::CreateHueRotateFilter(0.f); |
| 236 EXPECT_EQ(expected, blended); | 236 EXPECT_EQ(expected, blended); |
| 237 | 237 |
| 238 blended = FilterOperation::Blend(&from, &to, 0.75); | 238 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 239 expected = FilterOperation::CreateHueRotateFilter(6.f); | 239 expected = FilterOperation::CreateHueRotateFilter(6.f); |
| 240 EXPECT_EQ(expected, blended); | 240 EXPECT_EQ(expected, blended); |
| 241 | 241 |
| 242 blended = FilterOperation::Blend(&from, &to, 1.5); | 242 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 243 expected = FilterOperation::CreateHueRotateFilter(9.f); | 243 expected = FilterOperation::CreateHueRotateFilter(9.f); |
| 244 EXPECT_EQ(expected, blended); | 244 EXPECT_EQ(expected, blended); |
| 245 } | 245 } |
| 246 | 246 |
| 247 TEST(FilterOperationsTest, BlendHueRotateWithNull) { | 247 TEST(FilterOperationsTest, BlendHueRotateWithNull) { |
| 248 FilterOperation filter = FilterOperation::CreateHueRotateFilter(1.f); | 248 FilterOperation filter = FilterOperation::CreateHueRotateFilter(1.f); |
| 249 | 249 |
| 250 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 250 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 251 FilterOperation expected = FilterOperation::CreateHueRotateFilter(0.75f); | 251 FilterOperation expected = FilterOperation::CreateHueRotateFilter(0.75f); |
| 252 EXPECT_EQ(expected, blended); | 252 EXPECT_EQ(expected, blended); |
| 253 | 253 |
| 254 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 254 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 255 expected = FilterOperation::CreateHueRotateFilter(0.25f); | 255 expected = FilterOperation::CreateHueRotateFilter(0.25f); |
| 256 EXPECT_EQ(expected, blended); | 256 EXPECT_EQ(expected, blended); |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST(FilterOperationsTest, BlendInvertFilters) { | 259 TEST(FilterOperationsTest, BlendInvertFilters) { |
| 260 FilterOperation from = FilterOperation::CreateInvertFilter(0.25f); | 260 FilterOperation from = FilterOperation::CreateInvertFilter(0.25f); |
| 261 FilterOperation to = FilterOperation::CreateInvertFilter(0.75f); | 261 FilterOperation to = FilterOperation::CreateInvertFilter(0.75f); |
| 262 | 262 |
| 263 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 263 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 264 FilterOperation expected = FilterOperation::CreateInvertFilter(0.f); | 264 FilterOperation expected = FilterOperation::CreateInvertFilter(0.f); |
| 265 EXPECT_EQ(expected, blended); | 265 EXPECT_EQ(expected, blended); |
| 266 | 266 |
| 267 blended = FilterOperation::Blend(&from, &to, 0.75); | 267 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 268 expected = FilterOperation::CreateInvertFilter(0.625f); | 268 expected = FilterOperation::CreateInvertFilter(0.625f); |
| 269 EXPECT_EQ(expected, blended); | 269 EXPECT_EQ(expected, blended); |
| 270 | 270 |
| 271 blended = FilterOperation::Blend(&from, &to, 1.8); | 271 blended = FilterOperation::Blend(&from, &to, 1.8); |
| 272 expected = FilterOperation::CreateInvertFilter(1.f); | 272 expected = FilterOperation::CreateInvertFilter(1.f); |
| 273 EXPECT_EQ(expected, blended); | 273 EXPECT_EQ(expected, blended); |
| 274 } | 274 } |
| 275 | 275 |
| 276 TEST(FilterOperationsTest, BlendInvertWithNull) { | 276 TEST(FilterOperationsTest, BlendInvertWithNull) { |
| 277 FilterOperation filter = FilterOperation::CreateInvertFilter(1.f); | 277 FilterOperation filter = FilterOperation::CreateInvertFilter(1.f); |
| 278 | 278 |
| 279 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 279 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 280 FilterOperation expected = FilterOperation::CreateInvertFilter(0.75f); | 280 FilterOperation expected = FilterOperation::CreateInvertFilter(0.75f); |
| 281 EXPECT_EQ(expected, blended); | 281 EXPECT_EQ(expected, blended); |
| 282 | 282 |
| 283 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 283 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 284 expected = FilterOperation::CreateInvertFilter(0.25f); | 284 expected = FilterOperation::CreateInvertFilter(0.25f); |
| 285 EXPECT_EQ(expected, blended); | 285 EXPECT_EQ(expected, blended); |
| 286 } | 286 } |
| 287 | 287 |
| 288 TEST(FilterOperationsTest, BlendBrightnessFilters) { | 288 TEST(FilterOperationsTest, BlendBrightnessFilters) { |
| 289 FilterOperation from = FilterOperation::CreateBrightnessFilter(3.f); | 289 FilterOperation from = FilterOperation::CreateBrightnessFilter(3.f); |
| 290 FilterOperation to = FilterOperation::CreateBrightnessFilter(7.f); | 290 FilterOperation to = FilterOperation::CreateBrightnessFilter(7.f); |
| 291 | 291 |
| 292 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.9); | 292 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.9); |
| 293 FilterOperation expected = FilterOperation::CreateBrightnessFilter(0.f); | 293 FilterOperation expected = FilterOperation::CreateBrightnessFilter(0.f); |
| 294 EXPECT_EQ(expected, blended); | 294 EXPECT_EQ(expected, blended); |
| 295 | 295 |
| 296 blended = FilterOperation::Blend(&from, &to, 0.75); | 296 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 297 expected = FilterOperation::CreateBrightnessFilter(6.f); | 297 expected = FilterOperation::CreateBrightnessFilter(6.f); |
| 298 EXPECT_EQ(expected, blended); | 298 EXPECT_EQ(expected, blended); |
| 299 | 299 |
| 300 blended = FilterOperation::Blend(&from, &to, 1.5); | 300 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 301 expected = FilterOperation::CreateBrightnessFilter(9.f); | 301 expected = FilterOperation::CreateBrightnessFilter(9.f); |
| 302 EXPECT_EQ(expected, blended); | 302 EXPECT_EQ(expected, blended); |
| 303 } | 303 } |
| 304 | 304 |
| 305 TEST(FilterOperationsTest, BlendBrightnessWithNull) { | 305 TEST(FilterOperationsTest, BlendBrightnessWithNull) { |
| 306 FilterOperation filter = FilterOperation::CreateBrightnessFilter(0.f); | 306 FilterOperation filter = FilterOperation::CreateBrightnessFilter(0.f); |
| 307 | 307 |
| 308 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 308 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 309 FilterOperation expected = FilterOperation::CreateBrightnessFilter(0.25f); | 309 FilterOperation expected = FilterOperation::CreateBrightnessFilter(0.25f); |
| 310 EXPECT_EQ(expected, blended); | 310 EXPECT_EQ(expected, blended); |
| 311 | 311 |
| 312 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 312 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 313 expected = FilterOperation::CreateBrightnessFilter(0.75f); | 313 expected = FilterOperation::CreateBrightnessFilter(0.75f); |
| 314 EXPECT_EQ(expected, blended); | 314 EXPECT_EQ(expected, blended); |
| 315 } | 315 } |
| 316 | 316 |
| 317 TEST(FilterOperationsTest, BlendContrastFilters) { | 317 TEST(FilterOperationsTest, BlendContrastFilters) { |
| 318 FilterOperation from = FilterOperation::CreateContrastFilter(3.f); | 318 FilterOperation from = FilterOperation::CreateContrastFilter(3.f); |
| 319 FilterOperation to = FilterOperation::CreateContrastFilter(7.f); | 319 FilterOperation to = FilterOperation::CreateContrastFilter(7.f); |
| 320 | 320 |
| 321 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.9); | 321 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.9); |
| 322 FilterOperation expected = FilterOperation::CreateContrastFilter(0.f); | 322 FilterOperation expected = FilterOperation::CreateContrastFilter(0.f); |
| 323 EXPECT_EQ(expected, blended); | 323 EXPECT_EQ(expected, blended); |
| 324 | 324 |
| 325 blended = FilterOperation::Blend(&from, &to, 0.75); | 325 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 326 expected = FilterOperation::CreateContrastFilter(6.f); | 326 expected = FilterOperation::CreateContrastFilter(6.f); |
| 327 EXPECT_EQ(expected, blended); | 327 EXPECT_EQ(expected, blended); |
| 328 | 328 |
| 329 blended = FilterOperation::Blend(&from, &to, 1.5); | 329 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 330 expected = FilterOperation::CreateContrastFilter(9.f); | 330 expected = FilterOperation::CreateContrastFilter(9.f); |
| 331 EXPECT_EQ(expected, blended); | 331 EXPECT_EQ(expected, blended); |
| 332 } | 332 } |
| 333 | 333 |
| 334 TEST(FilterOperationsTest, BlendContrastWithNull) { | 334 TEST(FilterOperationsTest, BlendContrastWithNull) { |
| 335 FilterOperation filter = FilterOperation::CreateContrastFilter(0.f); | 335 FilterOperation filter = FilterOperation::CreateContrastFilter(0.f); |
| 336 | 336 |
| 337 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 337 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 338 FilterOperation expected = FilterOperation::CreateContrastFilter(0.25f); | 338 FilterOperation expected = FilterOperation::CreateContrastFilter(0.25f); |
| 339 EXPECT_EQ(expected, blended); | 339 EXPECT_EQ(expected, blended); |
| 340 | 340 |
| 341 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 341 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 342 expected = FilterOperation::CreateContrastFilter(0.75f); | 342 expected = FilterOperation::CreateContrastFilter(0.75f); |
| 343 EXPECT_EQ(expected, blended); | 343 EXPECT_EQ(expected, blended); |
| 344 } | 344 } |
| 345 | 345 |
| 346 TEST(FilterOperationsTest, BlendOpacityFilters) { | 346 TEST(FilterOperationsTest, BlendOpacityFilters) { |
| 347 FilterOperation from = FilterOperation::CreateOpacityFilter(0.25f); | 347 FilterOperation from = FilterOperation::CreateOpacityFilter(0.25f); |
| 348 FilterOperation to = FilterOperation::CreateOpacityFilter(0.75f); | 348 FilterOperation to = FilterOperation::CreateOpacityFilter(0.75f); |
| 349 | 349 |
| 350 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 350 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 351 FilterOperation expected = FilterOperation::CreateOpacityFilter(0.f); | 351 FilterOperation expected = FilterOperation::CreateOpacityFilter(0.f); |
| 352 EXPECT_EQ(expected, blended); | 352 EXPECT_EQ(expected, blended); |
| 353 | 353 |
| 354 blended = FilterOperation::Blend(&from, &to, 0.75); | 354 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 355 expected = FilterOperation::CreateOpacityFilter(0.625f); | 355 expected = FilterOperation::CreateOpacityFilter(0.625f); |
| 356 EXPECT_EQ(expected, blended); | 356 EXPECT_EQ(expected, blended); |
| 357 | 357 |
| 358 blended = FilterOperation::Blend(&from, &to, 1.8); | 358 blended = FilterOperation::Blend(&from, &to, 1.8); |
| 359 expected = FilterOperation::CreateOpacityFilter(1.f); | 359 expected = FilterOperation::CreateOpacityFilter(1.f); |
| 360 EXPECT_EQ(expected, blended); | 360 EXPECT_EQ(expected, blended); |
| 361 } | 361 } |
| 362 | 362 |
| 363 TEST(FilterOperationsTest, BlendOpacityWithNull) { | 363 TEST(FilterOperationsTest, BlendOpacityWithNull) { |
| 364 FilterOperation filter = FilterOperation::CreateOpacityFilter(0.f); | 364 FilterOperation filter = FilterOperation::CreateOpacityFilter(0.f); |
| 365 | 365 |
| 366 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 366 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 367 FilterOperation expected = FilterOperation::CreateOpacityFilter(0.25f); | 367 FilterOperation expected = FilterOperation::CreateOpacityFilter(0.25f); |
| 368 EXPECT_EQ(expected, blended); | 368 EXPECT_EQ(expected, blended); |
| 369 | 369 |
| 370 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 370 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 371 expected = FilterOperation::CreateOpacityFilter(0.75f); | 371 expected = FilterOperation::CreateOpacityFilter(0.75f); |
| 372 EXPECT_EQ(expected, blended); | 372 EXPECT_EQ(expected, blended); |
| 373 } | 373 } |
| 374 | 374 |
| 375 TEST(FilterOperationsTest, BlendBlurFilters) { | 375 TEST(FilterOperationsTest, BlendBlurFilters) { |
| 376 FilterOperation from = FilterOperation::CreateBlurFilter(3.f); | 376 FilterOperation from = FilterOperation::CreateBlurFilter(3.f); |
| 377 FilterOperation to = FilterOperation::CreateBlurFilter(7.f); | 377 FilterOperation to = FilterOperation::CreateBlurFilter(7.f); |
| 378 | 378 |
| 379 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.9); | 379 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.9); |
| 380 FilterOperation expected = FilterOperation::CreateBlurFilter(0.f); | 380 FilterOperation expected = FilterOperation::CreateBlurFilter(0.f); |
| 381 EXPECT_EQ(expected, blended); | 381 EXPECT_EQ(expected, blended); |
| 382 | 382 |
| 383 blended = FilterOperation::Blend(&from, &to, 0.75); | 383 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 384 expected = FilterOperation::CreateBlurFilter(6.f); | 384 expected = FilterOperation::CreateBlurFilter(6.f); |
| 385 EXPECT_EQ(expected, blended); | 385 EXPECT_EQ(expected, blended); |
| 386 | 386 |
| 387 blended = FilterOperation::Blend(&from, &to, 1.5); | 387 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 388 expected = FilterOperation::CreateBlurFilter(9.f); | 388 expected = FilterOperation::CreateBlurFilter(9.f); |
| 389 EXPECT_EQ(expected, blended); | 389 EXPECT_EQ(expected, blended); |
| 390 } | 390 } |
| 391 | 391 |
| 392 TEST(FilterOperationsTest, BlendBlurWithNull) { | 392 TEST(FilterOperationsTest, BlendBlurWithNull) { |
| 393 FilterOperation filter = FilterOperation::CreateBlurFilter(1.f); | 393 FilterOperation filter = FilterOperation::CreateBlurFilter(1.f); |
| 394 | 394 |
| 395 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 395 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 396 FilterOperation expected = FilterOperation::CreateBlurFilter(0.75f); | 396 FilterOperation expected = FilterOperation::CreateBlurFilter(0.75f); |
| 397 EXPECT_EQ(expected, blended); | 397 EXPECT_EQ(expected, blended); |
| 398 | 398 |
| 399 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 399 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 400 expected = FilterOperation::CreateBlurFilter(0.25f); | 400 expected = FilterOperation::CreateBlurFilter(0.25f); |
| 401 EXPECT_EQ(expected, blended); | 401 EXPECT_EQ(expected, blended); |
| 402 } | 402 } |
| 403 | 403 |
| 404 TEST(FilterOperationsTest, BlendDropShadowFilters) { | 404 TEST(FilterOperationsTest, BlendDropShadowFilters) { |
| 405 FilterOperation from = FilterOperation::CreateDropShadowFilter( | 405 FilterOperation from = FilterOperation::CreateDropShadowFilter( |
| 406 gfx::Point(0, 0), 2.f, SkColorSetARGB(15, 34, 68, 136)); | 406 gfx::Point(0, 0), 2.f, SkColorSetARGB(15, 34, 68, 136)); |
| 407 FilterOperation to = FilterOperation::CreateDropShadowFilter( | 407 FilterOperation to = FilterOperation::CreateDropShadowFilter( |
| 408 gfx::Point(3, 5), 6.f, SkColorSetARGB(51, 30, 60, 120)); | 408 gfx::Point(3, 5), 6.f, SkColorSetARGB(51, 30, 60, 120)); |
| 409 | 409 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 425 blended = FilterOperation::Blend(&from, &to, 1.5); | 425 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 426 expected = FilterOperation::CreateDropShadowFilter( | 426 expected = FilterOperation::CreateDropShadowFilter( |
| 427 gfx::Point(5, 8), 8.f, SkColorSetARGB(69, 30, 59, 118)); | 427 gfx::Point(5, 8), 8.f, SkColorSetARGB(69, 30, 59, 118)); |
| 428 EXPECT_EQ(expected, blended); | 428 EXPECT_EQ(expected, blended); |
| 429 } | 429 } |
| 430 | 430 |
| 431 TEST(FilterOperationsTest, BlendDropShadowWithNull) { | 431 TEST(FilterOperationsTest, BlendDropShadowWithNull) { |
| 432 FilterOperation filter = FilterOperation::CreateDropShadowFilter( | 432 FilterOperation filter = FilterOperation::CreateDropShadowFilter( |
| 433 gfx::Point(4, 4), 4.f, SkColorSetARGB(255, 40, 0, 0)); | 433 gfx::Point(4, 4), 4.f, SkColorSetARGB(255, 40, 0, 0)); |
| 434 | 434 |
| 435 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 435 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 436 FilterOperation expected = FilterOperation::CreateDropShadowFilter( | 436 FilterOperation expected = FilterOperation::CreateDropShadowFilter( |
| 437 gfx::Point(3, 3), 3.f, SkColorSetARGB(191, 40, 0, 0)); | 437 gfx::Point(3, 3), 3.f, SkColorSetARGB(191, 40, 0, 0)); |
| 438 EXPECT_EQ(expected, blended); | 438 EXPECT_EQ(expected, blended); |
| 439 | 439 |
| 440 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 440 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 441 expected = FilterOperation::CreateDropShadowFilter( | 441 expected = FilterOperation::CreateDropShadowFilter( |
| 442 gfx::Point(1, 1), 1.f, SkColorSetARGB(64, 40, 0, 0)); | 442 gfx::Point(1, 1), 1.f, SkColorSetARGB(64, 40, 0, 0)); |
| 443 EXPECT_EQ(expected, blended); | 443 EXPECT_EQ(expected, blended); |
| 444 } | 444 } |
| 445 | 445 |
| 446 TEST(FilterOperationsTest, BlendZoomFilters) { | 446 TEST(FilterOperationsTest, BlendZoomFilters) { |
| 447 FilterOperation from = FilterOperation::CreateZoomFilter(2.f, 3); | 447 FilterOperation from = FilterOperation::CreateZoomFilter(2.f, 3); |
| 448 FilterOperation to = FilterOperation::CreateZoomFilter(6.f, 0); | 448 FilterOperation to = FilterOperation::CreateZoomFilter(6.f, 0); |
| 449 | 449 |
| 450 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 450 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 451 FilterOperation expected = FilterOperation::CreateZoomFilter(1.f, 5); | 451 FilterOperation expected = FilterOperation::CreateZoomFilter(1.f, 5); |
| 452 EXPECT_EQ(expected, blended); | 452 EXPECT_EQ(expected, blended); |
| 453 | 453 |
| 454 blended = FilterOperation::Blend(&from, &to, 0.75); | 454 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 455 expected = FilterOperation::CreateZoomFilter(5.f, 1); | 455 expected = FilterOperation::CreateZoomFilter(5.f, 1); |
| 456 EXPECT_EQ(expected, blended); | 456 EXPECT_EQ(expected, blended); |
| 457 | 457 |
| 458 blended = FilterOperation::Blend(&from, &to, 1.5); | 458 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 459 expected = FilterOperation::CreateZoomFilter(8.f, 0); | 459 expected = FilterOperation::CreateZoomFilter(8.f, 0); |
| 460 EXPECT_EQ(expected, blended); | 460 EXPECT_EQ(expected, blended); |
| 461 } | 461 } |
| 462 | 462 |
| 463 TEST(FilterOperationsTest, BlendZoomWithNull) { | 463 TEST(FilterOperationsTest, BlendZoomWithNull) { |
| 464 FilterOperation filter = FilterOperation::CreateZoomFilter(2.f, 1); | 464 FilterOperation filter = FilterOperation::CreateZoomFilter(2.f, 1); |
| 465 | 465 |
| 466 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 466 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 467 FilterOperation expected = FilterOperation::CreateZoomFilter(1.75f, 1); | 467 FilterOperation expected = FilterOperation::CreateZoomFilter(1.75f, 1); |
| 468 EXPECT_EQ(expected, blended); | 468 EXPECT_EQ(expected, blended); |
| 469 | 469 |
| 470 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 470 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 471 expected = FilterOperation::CreateZoomFilter(1.25f, 0); | 471 expected = FilterOperation::CreateZoomFilter(1.25f, 0); |
| 472 EXPECT_EQ(expected, blended); | 472 EXPECT_EQ(expected, blended); |
| 473 } | 473 } |
| 474 | 474 |
| 475 TEST(FilterOperationsTest, BlendSaturatingBrightnessFilters) { | 475 TEST(FilterOperationsTest, BlendSaturatingBrightnessFilters) { |
| 476 FilterOperation from = FilterOperation::CreateSaturatingBrightnessFilter(3.f); | 476 FilterOperation from = FilterOperation::CreateSaturatingBrightnessFilter(3.f); |
| 477 FilterOperation to = FilterOperation::CreateSaturatingBrightnessFilter(7.f); | 477 FilterOperation to = FilterOperation::CreateSaturatingBrightnessFilter(7.f); |
| 478 | 478 |
| 479 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 479 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
| 480 FilterOperation expected = | 480 FilterOperation expected = |
| 481 FilterOperation::CreateSaturatingBrightnessFilter(0.f); | 481 FilterOperation::CreateSaturatingBrightnessFilter(0.f); |
| 482 EXPECT_EQ(expected, blended); | 482 EXPECT_EQ(expected, blended); |
| 483 | 483 |
| 484 blended = FilterOperation::Blend(&from, &to, 0.75); | 484 blended = FilterOperation::Blend(&from, &to, 0.75); |
| 485 expected = FilterOperation::CreateSaturatingBrightnessFilter(6.f); | 485 expected = FilterOperation::CreateSaturatingBrightnessFilter(6.f); |
| 486 EXPECT_EQ(expected, blended); | 486 EXPECT_EQ(expected, blended); |
| 487 | 487 |
| 488 blended = FilterOperation::Blend(&from, &to, 1.5); | 488 blended = FilterOperation::Blend(&from, &to, 1.5); |
| 489 expected = FilterOperation::CreateSaturatingBrightnessFilter(9.f); | 489 expected = FilterOperation::CreateSaturatingBrightnessFilter(9.f); |
| 490 EXPECT_EQ(expected, blended); | 490 EXPECT_EQ(expected, blended); |
| 491 } | 491 } |
| 492 | 492 |
| 493 TEST(FilterOperationsTest, BlendSaturatingBrightnessWithNull) { | 493 TEST(FilterOperationsTest, BlendSaturatingBrightnessWithNull) { |
| 494 FilterOperation filter = | 494 FilterOperation filter = |
| 495 FilterOperation::CreateSaturatingBrightnessFilter(1.f); | 495 FilterOperation::CreateSaturatingBrightnessFilter(1.f); |
| 496 | 496 |
| 497 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 497 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 498 FilterOperation expected = | 498 FilterOperation expected = |
| 499 FilterOperation::CreateSaturatingBrightnessFilter(0.75f); | 499 FilterOperation::CreateSaturatingBrightnessFilter(0.75f); |
| 500 EXPECT_EQ(expected, blended); | 500 EXPECT_EQ(expected, blended); |
| 501 | 501 |
| 502 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 502 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 503 expected = FilterOperation::CreateSaturatingBrightnessFilter(0.25f); | 503 expected = FilterOperation::CreateSaturatingBrightnessFilter(0.25f); |
| 504 EXPECT_EQ(expected, blended); | 504 EXPECT_EQ(expected, blended); |
| 505 } | 505 } |
| 506 | 506 |
| 507 TEST(FilterOperationsTest, BlendReferenceFilters) { | 507 TEST(FilterOperationsTest, BlendReferenceFilters) { |
| 508 skia::RefPtr<SkImageFilter> from_filter = | 508 skia::RefPtr<SkImageFilter> from_filter = |
| 509 skia::AdoptRef(SkBlurImageFilter::Create(1.f, 1.f)); | 509 skia::AdoptRef(SkBlurImageFilter::Create(1.f, 1.f)); |
| 510 skia::RefPtr<SkImageFilter> to_filter = | 510 skia::RefPtr<SkImageFilter> to_filter = |
| 511 skia::AdoptRef(SkBlurImageFilter::Create(2.f, 2.f)); | 511 skia::AdoptRef(SkBlurImageFilter::Create(2.f, 2.f)); |
| 512 FilterOperation from = FilterOperation::CreateReferenceFilter(from_filter); | 512 FilterOperation from = FilterOperation::CreateReferenceFilter(from_filter); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 525 EXPECT_EQ(to, blended); | 525 EXPECT_EQ(to, blended); |
| 526 } | 526 } |
| 527 | 527 |
| 528 TEST(FilterOperationsTest, BlendReferenceWithNull) { | 528 TEST(FilterOperationsTest, BlendReferenceWithNull) { |
| 529 skia::RefPtr<SkImageFilter> image_filter = | 529 skia::RefPtr<SkImageFilter> image_filter = |
| 530 skia::AdoptRef(SkBlurImageFilter::Create(1.f, 1.f)); | 530 skia::AdoptRef(SkBlurImageFilter::Create(1.f, 1.f)); |
| 531 FilterOperation filter = FilterOperation::CreateReferenceFilter(image_filter); | 531 FilterOperation filter = FilterOperation::CreateReferenceFilter(image_filter); |
| 532 FilterOperation null_filter = | 532 FilterOperation null_filter = |
| 533 FilterOperation::CreateReferenceFilter(skia::RefPtr<SkImageFilter>()); | 533 FilterOperation::CreateReferenceFilter(skia::RefPtr<SkImageFilter>()); |
| 534 | 534 |
| 535 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 535 FilterOperation blended = FilterOperation::Blend(&filter, nullptr, 0.25); |
| 536 EXPECT_EQ(filter, blended); | 536 EXPECT_EQ(filter, blended); |
| 537 blended = FilterOperation::Blend(&filter, NULL, 0.75); | 537 blended = FilterOperation::Blend(&filter, nullptr, 0.75); |
| 538 EXPECT_EQ(null_filter, blended); | 538 EXPECT_EQ(null_filter, blended); |
| 539 | 539 |
| 540 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 540 blended = FilterOperation::Blend(nullptr, &filter, 0.25); |
| 541 EXPECT_EQ(null_filter, blended); | 541 EXPECT_EQ(null_filter, blended); |
| 542 blended = FilterOperation::Blend(NULL, &filter, 0.75); | 542 blended = FilterOperation::Blend(nullptr, &filter, 0.75); |
| 543 EXPECT_EQ(filter, blended); | 543 EXPECT_EQ(filter, blended); |
| 544 } | 544 } |
| 545 | 545 |
| 546 // Tests blending non-empty sequences that have the same length and matching | 546 // Tests blending non-empty sequences that have the same length and matching |
| 547 // operations. | 547 // operations. |
| 548 TEST(FilterOperationsTest, BlendMatchingSequences) { | 548 TEST(FilterOperationsTest, BlendMatchingSequences) { |
| 549 FilterOperations from; | 549 FilterOperations from; |
| 550 FilterOperations to; | 550 FilterOperations to; |
| 551 | 551 |
| 552 from.Append(FilterOperation::CreateBlurFilter(0.f)); | 552 from.Append(FilterOperation::CreateBlurFilter(0.f)); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 blended = to.Blend(from, -0.75); | 694 blended = to.Blend(from, -0.75); |
| 695 EXPECT_EQ(to, blended); | 695 EXPECT_EQ(to, blended); |
| 696 blended = to.Blend(from, 0.75); | 696 blended = to.Blend(from, 0.75); |
| 697 EXPECT_EQ(to, blended); | 697 EXPECT_EQ(to, blended); |
| 698 blended = to.Blend(from, 1.5); | 698 blended = to.Blend(from, 1.5); |
| 699 EXPECT_EQ(to, blended); | 699 EXPECT_EQ(to, blended); |
| 700 } | 700 } |
| 701 | 701 |
| 702 } // namespace | 702 } // namespace |
| 703 } // namespace cc | 703 } // namespace cc |
| OLD | NEW |