| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tiles/software_image_decode_controller.h" | 5 #include "cc/tiles/software_image_decode_controller.h" |
| 6 | 6 |
| 7 #include "cc/playback/draw_image.h" | 7 #include "cc/playback/draw_image.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 EXPECT_TRUE(need_unref); | 395 EXPECT_TRUE(need_unref); |
| 396 EXPECT_TRUE(high_quality_task); | 396 EXPECT_TRUE(high_quality_task); |
| 397 | 397 |
| 398 DrawImage medium_quality_draw_image( | 398 DrawImage medium_quality_draw_image( |
| 399 image.get(), SkIRect::MakeWH(image->width(), image->height()), | 399 image.get(), SkIRect::MakeWH(image->width(), image->height()), |
| 400 kMedium_SkFilterQuality, | 400 kMedium_SkFilterQuality, |
| 401 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable)); | 401 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable)); |
| 402 scoped_refptr<ImageDecodeTask> medium_quality_task; | 402 scoped_refptr<ImageDecodeTask> medium_quality_task; |
| 403 need_unref = controller.GetTaskForImageAndRef( | 403 need_unref = controller.GetTaskForImageAndRef( |
| 404 medium_quality_draw_image, prepare_tiles_id, &medium_quality_task); | 404 medium_quality_draw_image, prepare_tiles_id, &medium_quality_task); |
| 405 // Medium quality isn't handled by the controller, so it won't ref it. Note | 405 EXPECT_TRUE(need_unref); |
| 406 // that this will change when medium quality is handled and will need to be | |
| 407 // updated. | |
| 408 EXPECT_FALSE(need_unref); | |
| 409 EXPECT_TRUE(medium_quality_task); | 406 EXPECT_TRUE(medium_quality_task); |
| 410 EXPECT_TRUE(high_quality_task.get() != medium_quality_task.get()); | 407 EXPECT_TRUE(high_quality_task.get() != medium_quality_task.get()); |
| 411 | 408 |
| 412 DrawImage low_quality_draw_image( | 409 DrawImage low_quality_draw_image( |
| 413 image.get(), SkIRect::MakeWH(image->width(), image->height()), | 410 image.get(), SkIRect::MakeWH(image->width(), image->height()), |
| 414 kLow_SkFilterQuality, | 411 kLow_SkFilterQuality, |
| 415 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable)); | 412 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable)); |
| 416 scoped_refptr<ImageDecodeTask> low_quality_task; | 413 scoped_refptr<ImageDecodeTask> low_quality_task; |
| 417 need_unref = controller.GetTaskForImageAndRef( | 414 need_unref = controller.GetTaskForImageAndRef( |
| 418 low_quality_draw_image, prepare_tiles_id, &low_quality_task); | 415 low_quality_draw_image, prepare_tiles_id, &low_quality_task); |
| 419 EXPECT_TRUE(need_unref); | 416 EXPECT_TRUE(need_unref); |
| 420 EXPECT_TRUE(low_quality_task); | 417 EXPECT_TRUE(low_quality_task); |
| 421 EXPECT_TRUE(high_quality_task.get() != low_quality_task.get()); | 418 EXPECT_TRUE(high_quality_task.get() != low_quality_task.get()); |
| 422 EXPECT_TRUE(medium_quality_task.get() != low_quality_task.get()); | 419 EXPECT_TRUE(medium_quality_task.get() != low_quality_task.get()); |
| 423 | 420 |
| 424 controller.UnrefImage(high_quality_draw_image); | 421 controller.UnrefImage(high_quality_draw_image); |
| 422 controller.UnrefImage(medium_quality_draw_image); |
| 425 controller.UnrefImage(low_quality_draw_image); | 423 controller.UnrefImage(low_quality_draw_image); |
| 426 } | 424 } |
| 427 | 425 |
| 428 TEST(SoftwareImageDecodeControllerTest, GetTaskForImageSameImageDifferentSize) { | 426 TEST(SoftwareImageDecodeControllerTest, GetTaskForImageSameImageDifferentSize) { |
| 429 SoftwareImageDecodeController controller; | 427 SoftwareImageDecodeController controller; |
| 430 skia::RefPtr<SkImage> image = CreateImage(100, 100); | 428 skia::RefPtr<SkImage> image = CreateImage(100, 100); |
| 431 bool is_decomposable = true; | 429 bool is_decomposable = true; |
| 432 uint64_t prepare_tiles_id = 1; | 430 uint64_t prepare_tiles_id = 1; |
| 433 SkFilterQuality quality = kHigh_SkFilterQuality; | 431 SkFilterQuality quality = kHigh_SkFilterQuality; |
| 434 | 432 |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 // SkImage object. | 1031 // SkImage object. |
| 1034 EXPECT_TRUE(decoded_draw_image.image() != image.get()); | 1032 EXPECT_TRUE(decoded_draw_image.image() != image.get()); |
| 1035 EXPECT_EQ(kNone_SkFilterQuality, decoded_draw_image.filter_quality()); | 1033 EXPECT_EQ(kNone_SkFilterQuality, decoded_draw_image.filter_quality()); |
| 1036 EXPECT_TRUE(decoded_draw_image.is_scale_adjustment_identity()); | 1034 EXPECT_TRUE(decoded_draw_image.is_scale_adjustment_identity()); |
| 1037 | 1035 |
| 1038 controller.DrawWithImageFinished(draw_image, decoded_draw_image); | 1036 controller.DrawWithImageFinished(draw_image, decoded_draw_image); |
| 1039 controller.UnrefImage(draw_image); | 1037 controller.UnrefImage(draw_image); |
| 1040 } | 1038 } |
| 1041 } // namespace | 1039 } // namespace |
| 1042 } // namespace cc | 1040 } // namespace cc |
| OLD | NEW |