| 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" |
| 6 #include "cc/paint/display_item_list.h" | 7 #include "cc/paint/display_item_list.h" |
| 7 #include "cc/test/skia_common.h" | 8 #include "cc/test/skia_common.h" |
| 8 #include "cc/test/test_skcanvas.h" | 9 #include "cc/test/test_skcanvas.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/effects/SkDashPathEffect.h" | 11 #include "third_party/skia/include/effects/SkDashPathEffect.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 template <typename T> | 15 template <typename T> |
| 15 void CheckRefCnt(const T& obj, int32_t count) { | 16 void CheckRefCnt(const T& obj, int32_t count) { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 list->Finalize(); | 434 list->Finalize(); |
| 434 PaintOpBuffer new_buffer; | 435 PaintOpBuffer new_buffer; |
| 435 new_buffer.push<DrawDisplayItemListOp>(list); | 436 new_buffer.push<DrawDisplayItemListOp>(list); |
| 436 EXPECT_TRUE(new_buffer.HasDiscardableImages()); | 437 EXPECT_TRUE(new_buffer.HasDiscardableImages()); |
| 437 } | 438 } |
| 438 | 439 |
| 439 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { | 440 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { |
| 440 PaintOpBuffer buffer; | 441 PaintOpBuffer buffer; |
| 441 PaintFlags flags; | 442 PaintFlags flags; |
| 442 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); | 443 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); |
| 443 flags.setShader( | 444 flags.setShader(base::MakeUnique<PaintShader>( |
| 444 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); | 445 image, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr)); |
| 445 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); | 446 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); |
| 446 EXPECT_TRUE(buffer.HasDiscardableImages()); | 447 EXPECT_TRUE(buffer.HasDiscardableImages()); |
| 447 } | 448 } |
| 448 | 449 |
| 449 TEST(PaintOpBufferTest, SlowPaths) { | 450 TEST(PaintOpBufferTest, SlowPaths) { |
| 450 auto buffer = sk_make_sp<PaintOpBuffer>(); | 451 auto buffer = sk_make_sp<PaintOpBuffer>(); |
| 451 EXPECT_EQ(buffer->numSlowPaths(), 0); | 452 EXPECT_EQ(buffer->numSlowPaths(), 0); |
| 452 | 453 |
| 453 // Op without slow paths | 454 // Op without slow paths |
| 454 PaintFlags noop_flags; | 455 PaintFlags noop_flags; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 491 |
| 491 // Drawing a record with slow paths into another adds the same | 492 // Drawing a record with slow paths into another adds the same |
| 492 // number of slow paths as the record. | 493 // number of slow paths as the record. |
| 493 auto buffer2 = sk_make_sp<PaintOpBuffer>(); | 494 auto buffer2 = sk_make_sp<PaintOpBuffer>(); |
| 494 EXPECT_EQ(buffer2->numSlowPaths(), 0); | 495 EXPECT_EQ(buffer2->numSlowPaths(), 0); |
| 495 buffer2->push<DrawRecordOp>(buffer); | 496 buffer2->push<DrawRecordOp>(buffer); |
| 496 EXPECT_EQ(buffer->numSlowPaths(), buffer2->numSlowPaths()); | 497 EXPECT_EQ(buffer->numSlowPaths(), buffer2->numSlowPaths()); |
| 497 } | 498 } |
| 498 | 499 |
| 499 } // namespace cc | 500 } // namespace cc |
| OLD | NEW |