| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/paint/paint_op_buffer.h" | 5 #include "cc/paint/paint_op_buffer.h" |
| 6 #include "base/memory/ptr_util.h" | |
| 7 #include "cc/paint/display_item_list.h" | 6 #include "cc/paint/display_item_list.h" |
| 8 #include "cc/test/skia_common.h" | 7 #include "cc/test/skia_common.h" |
| 9 #include "cc/test/test_skcanvas.h" | 8 #include "cc/test/test_skcanvas.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/skia/include/effects/SkDashPathEffect.h" | 10 #include "third_party/skia/include/effects/SkDashPathEffect.h" |
| 12 | 11 |
| 13 using testing::_; | 12 using testing::_; |
| 14 using testing::Property; | 13 using testing::Property; |
| 15 using testing::Mock; | 14 using testing::Mock; |
| 16 | 15 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 list->Finalize(); | 440 list->Finalize(); |
| 442 PaintOpBuffer new_buffer; | 441 PaintOpBuffer new_buffer; |
| 443 new_buffer.push<DrawDisplayItemListOp>(list); | 442 new_buffer.push<DrawDisplayItemListOp>(list); |
| 444 EXPECT_TRUE(new_buffer.HasDiscardableImages()); | 443 EXPECT_TRUE(new_buffer.HasDiscardableImages()); |
| 445 } | 444 } |
| 446 | 445 |
| 447 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { | 446 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { |
| 448 PaintOpBuffer buffer; | 447 PaintOpBuffer buffer; |
| 449 PaintFlags flags; | 448 PaintFlags flags; |
| 450 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); | 449 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); |
| 451 flags.setShader(PaintShader::MakeImage(std::move(image), | 450 flags.setShader( |
| 452 SkShader::kClamp_TileMode, | 451 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); |
| 453 SkShader::kClamp_TileMode, nullptr)); | |
| 454 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); | 452 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); |
| 455 EXPECT_TRUE(buffer.HasDiscardableImages()); | 453 EXPECT_TRUE(buffer.HasDiscardableImages()); |
| 456 } | 454 } |
| 457 | 455 |
| 458 TEST(PaintOpBufferTest, SlowPaths) { | 456 TEST(PaintOpBufferTest, SlowPaths) { |
| 459 auto buffer = sk_make_sp<PaintOpBuffer>(); | 457 auto buffer = sk_make_sp<PaintOpBuffer>(); |
| 460 EXPECT_EQ(buffer->numSlowPaths(), 0); | 458 EXPECT_EQ(buffer->numSlowPaths(), 0); |
| 461 | 459 |
| 462 // Op without slow paths | 460 // Op without slow paths |
| 463 PaintFlags noop_flags; | 461 PaintFlags noop_flags; |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 EXPECT_CALL(canvas, OnSaveLayer()).InSequence(s); | 981 EXPECT_CALL(canvas, OnSaveLayer()).InSequence(s); |
| 984 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s); | 982 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s); |
| 985 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s); | 983 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s); |
| 986 EXPECT_CALL(canvas, willRestore()).InSequence(s); | 984 EXPECT_CALL(canvas, willRestore()).InSequence(s); |
| 987 // We will restore back to the original save count regardless with 2 restores. | 985 // We will restore back to the original save count regardless with 2 restores. |
| 988 EXPECT_CALL(canvas, willRestore()).InSequence(s); | 986 EXPECT_CALL(canvas, willRestore()).InSequence(s); |
| 989 buffer.PlaybackRanges({0}, {0}, &canvas); | 987 buffer.PlaybackRanges({0}, {0}, &canvas); |
| 990 } | 988 } |
| 991 | 989 |
| 992 } // namespace cc | 990 } // namespace cc |
| OLD | NEW |