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 "cc/paint/display_item_list.h" | 6 #include "cc/paint/display_item_list.h" |
7 #include "cc/test/skia_common.h" | 7 #include "cc/test/skia_common.h" |
8 #include "cc/test/test_skcanvas.h" | 8 #include "cc/test/test_skcanvas.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/effects/SkDashPathEffect.h" | 10 #include "third_party/skia/include/effects/SkDashPathEffect.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 427 |
428 TEST(PaintOpBufferTest, DiscardableImagesTracking_NoImageOp) { | 428 TEST(PaintOpBufferTest, DiscardableImagesTracking_NoImageOp) { |
429 PaintOpBuffer buffer; | 429 PaintOpBuffer buffer; |
430 PaintFlags flags; | 430 PaintFlags flags; |
431 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); | 431 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); |
432 EXPECT_FALSE(buffer.HasDiscardableImages()); | 432 EXPECT_FALSE(buffer.HasDiscardableImages()); |
433 } | 433 } |
434 | 434 |
435 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImage) { | 435 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImage) { |
436 PaintOpBuffer buffer; | 436 PaintOpBuffer buffer; |
437 PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100))); | 437 PaintImage image = PaintImage(PaintImage::GetNextId(), |
| 438 CreateDiscardableImage(gfx::Size(100, 100))); |
438 buffer.push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr); | 439 buffer.push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr); |
439 EXPECT_TRUE(buffer.HasDiscardableImages()); | 440 EXPECT_TRUE(buffer.HasDiscardableImages()); |
440 } | 441 } |
441 | 442 |
442 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImageRect) { | 443 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImageRect) { |
443 PaintOpBuffer buffer; | 444 PaintOpBuffer buffer; |
444 PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100))); | 445 PaintImage image = PaintImage(PaintImage::GetNextId(), |
| 446 CreateDiscardableImage(gfx::Size(100, 100))); |
445 buffer.push<DrawImageRectOp>( | 447 buffer.push<DrawImageRectOp>( |
446 image, SkRect::MakeWH(100, 100), SkRect::MakeWH(100, 100), nullptr, | 448 image, SkRect::MakeWH(100, 100), SkRect::MakeWH(100, 100), nullptr, |
447 PaintCanvas::SrcRectConstraint::kFast_SrcRectConstraint); | 449 PaintCanvas::SrcRectConstraint::kFast_SrcRectConstraint); |
448 EXPECT_TRUE(buffer.HasDiscardableImages()); | 450 EXPECT_TRUE(buffer.HasDiscardableImages()); |
449 } | 451 } |
450 | 452 |
451 TEST(PaintOpBufferTest, DiscardableImagesTracking_NestedDrawOp) { | 453 TEST(PaintOpBufferTest, DiscardableImagesTracking_NestedDrawOp) { |
452 sk_sp<PaintRecord> record = sk_make_sp<PaintRecord>(); | 454 sk_sp<PaintRecord> record = sk_make_sp<PaintRecord>(); |
453 PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100))); | 455 PaintImage image = PaintImage(PaintImage::GetNextId(), |
| 456 CreateDiscardableImage(gfx::Size(100, 100))); |
454 record->push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr); | 457 record->push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr); |
455 | 458 |
456 PaintOpBuffer buffer; | 459 PaintOpBuffer buffer; |
457 buffer.push<DrawRecordOp>(record); | 460 buffer.push<DrawRecordOp>(record); |
458 EXPECT_TRUE(buffer.HasDiscardableImages()); | 461 EXPECT_TRUE(buffer.HasDiscardableImages()); |
459 | 462 |
460 scoped_refptr<DisplayItemList> list = new DisplayItemList; | 463 scoped_refptr<DisplayItemList> list = new DisplayItemList; |
461 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 464 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
462 gfx::Rect(0, 0, 100, 100), record); | 465 gfx::Rect(0, 0, 100, 100), record); |
463 list->Finalize(); | 466 list->Finalize(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 523 |
521 // Drawing a record with slow paths into another adds the same | 524 // Drawing a record with slow paths into another adds the same |
522 // number of slow paths as the record. | 525 // number of slow paths as the record. |
523 auto buffer2 = sk_make_sp<PaintOpBuffer>(); | 526 auto buffer2 = sk_make_sp<PaintOpBuffer>(); |
524 EXPECT_EQ(buffer2->numSlowPaths(), 0); | 527 EXPECT_EQ(buffer2->numSlowPaths(), 0); |
525 buffer2->push<DrawRecordOp>(buffer); | 528 buffer2->push<DrawRecordOp>(buffer); |
526 EXPECT_EQ(buffer->numSlowPaths(), buffer2->numSlowPaths()); | 529 EXPECT_EQ(buffer->numSlowPaths(), buffer2->numSlowPaths()); |
527 } | 530 } |
528 | 531 |
529 } // namespace cc | 532 } // namespace cc |
OLD | NEW |