Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: cc/playback/display_item_list_unittest.cc

Issue 1538913002: cc: Restore GPU suitability check in cached_picture case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit tests Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/playback/display_item_list.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/playback/display_item_list.h" 5 #include "cc/playback/display_item_list.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/output/filter_operation.h" 9 #include "cc/output/filter_operation.h"
10 #include "cc/output/filter_operations.h" 10 #include "cc/output/filter_operations.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 path.lineTo(0, 100); 520 path.lineTo(0, 100);
521 path.lineTo(50, 50); 521 path.lineTo(50, 50);
522 path.lineTo(100, 100); 522 path.lineTo(100, 100);
523 path.lineTo(100, 0); 523 path.lineTo(100, 0);
524 path.close(); 524 path.close();
525 525
526 SkPaint paint; 526 SkPaint paint;
527 paint.setAntiAlias(true); 527 paint.setAntiAlias(true);
528 canvas->drawPath(path, paint); 528 canvas->drawPath(path, paint);
529 529
530 list->CreateAndAppendItem<DrawingDisplayItem>( 530 skia::RefPtr<SkPicture> suitable_picture =
531 kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture())); 531 skia::AdoptRef(recorder.endRecordingAsPicture());
532 list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, suitable_picture);
532 list->Finalize(); 533 list->Finalize();
533 534
534 // A single DrawingDisplayItem with a large AA concave path shouldn't trigger 535 // A single DrawingDisplayItem with a large AA concave path shouldn't trigger
535 // a veto. 536 // a veto.
536 EXPECT_TRUE(list->IsSuitableForGpuRasterization()); 537 EXPECT_TRUE(list->IsSuitableForGpuRasterization());
537 538
539 // Now check the RasterIntoCanvas path.
540 list = DisplayItemList::Create(layer_rect, settings);
541 DrawingDisplayItem suitable_item(suitable_picture);
542 list->RasterIntoCanvas(suitable_item);
543 list->Finalize();
544 EXPECT_TRUE(list->IsSuitableForGpuRasterization());
545
538 list = DisplayItemList::Create(layer_rect, settings); 546 list = DisplayItemList::Create(layer_rect, settings);
539 canvas = 547 canvas =
540 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect))); 548 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
541 for (int i = 0; i < 10; ++i) 549 for (int i = 0; i < 10; ++i)
542 canvas->drawPath(path, paint); 550 canvas->drawPath(path, paint);
543 list->CreateAndAppendItem<DrawingDisplayItem>( 551 skia::RefPtr<SkPicture> unsuitable_picture =
544 kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture())); 552 skia::AdoptRef(recorder.endRecordingAsPicture());
553 list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
554 unsuitable_picture);
545 list->Finalize(); 555 list->Finalize();
546 556
547 // A single DrawingDisplayItem with several large AA concave paths should 557 // A single DrawingDisplayItem with several large AA concave paths should
548 // trigger a veto. 558 // trigger a veto.
549 EXPECT_FALSE(list->IsSuitableForGpuRasterization()); 559 EXPECT_FALSE(list->IsSuitableForGpuRasterization());
560
561 // Now check the RasterIntoCanvas path.
562 list = DisplayItemList::Create(layer_rect, settings);
563 DrawingDisplayItem unsuitable_item(unsuitable_picture);
564 list->RasterIntoCanvas(unsuitable_item);
565 list->Finalize();
566 EXPECT_FALSE(list->IsSuitableForGpuRasterization());
550 } 567 }
551 568
552 TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) { 569 TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
553 gfx::Rect layer_rect(1000, 1000); 570 gfx::Rect layer_rect(1000, 1000);
554 SkPictureRecorder recorder; 571 SkPictureRecorder recorder;
555 skia::RefPtr<SkCanvas> canvas; 572 skia::RefPtr<SkCanvas> canvas;
556 skia::RefPtr<SkPicture> picture; 573 skia::RefPtr<SkPicture> picture;
557 574
558 DisplayItemListSettings settings; 575 DisplayItemListSettings settings;
559 settings.use_cached_picture = false; 576 settings.use_cached_picture = false;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 751
735 value = list->AsValue(false)->ToString(); 752 value = list->AsValue(false)->ToString();
736 EXPECT_EQ(value.find("\"items\":"), std::string::npos); 753 EXPECT_EQ(value.find("\"items\":"), std::string::npos);
737 EXPECT_NE(value.find("\"layer_rect\":[0,0,0,0]"), std::string::npos); 754 EXPECT_NE(value.find("\"layer_rect\":[0,0,0,0]"), std::string::npos);
738 // There should be no skp64 entry present as the items aren't included and the 755 // There should be no skp64 entry present as the items aren't included and the
739 // layer rect is empty. 756 // layer rect is empty.
740 EXPECT_EQ(value.find("\"skp64\":"), std::string::npos); 757 EXPECT_EQ(value.find("\"skp64\":"), std::string::npos);
741 } 758 }
742 759
743 } // namespace cc 760 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/display_item_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698