Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 void ValidateDisplayItemListSerialization(const gfx::Size& layer_size, | 77 void ValidateDisplayItemListSerialization(const gfx::Size& layer_size, |
| 78 scoped_refptr<DisplayItemList> list) { | 78 scoped_refptr<DisplayItemList> list) { |
| 79 list->Finalize(); | 79 list->Finalize(); |
| 80 | 80 |
| 81 // Serialize and deserialize the DisplayItemList. | 81 // Serialize and deserialize the DisplayItemList. |
| 82 proto::DisplayItemList proto; | 82 proto::DisplayItemList proto; |
| 83 list->ToProtobuf(&proto); | 83 list->ToProtobuf(&proto); |
| 84 scoped_refptr<DisplayItemList> new_list = | 84 scoped_refptr<DisplayItemList> new_list = |
| 85 DisplayItemList::CreateFromProto(proto); | 85 DisplayItemList::CreateFromProto(proto); |
| 86 | 86 |
| 87 // Finalize the DisplayItemLists to perform raster. | 87 EXPECT_TRUE( |
| 88 new_list->Finalize(); | 88 CompareDisplayListDrawingResults(gfx::Rect(layer_size), list, new_list)); |
|
vmpstr
2015/12/10 18:55:44
naming nit: If this is going to return true maybe
David Trainor- moved to gerrit
2015/12/10 21:51:27
Exactly the same length. Wut.
vmpstr
2015/12/10 21:55:49
Skillz.
| |
| 89 | |
| 90 const int pixel_size = 4 * layer_size.GetArea(); | |
| 91 | |
| 92 // Get the rendered contents of the old DisplayItemList. | |
| 93 scoped_ptr<unsigned char[]> pixels(new unsigned char[pixel_size]); | |
| 94 memset(pixels.get(), 0, pixel_size); | |
| 95 DrawDisplayList(pixels.get(), gfx::Rect(layer_size), list); | |
| 96 | |
| 97 // Get the rendered contents of the new DisplayItemList. | |
| 98 scoped_ptr<unsigned char[]> new_pixels(new unsigned char[pixel_size]); | |
| 99 memset(new_pixels.get(), 0, pixel_size); | |
| 100 DrawDisplayList(new_pixels.get(), gfx::Rect(layer_size), new_list); | |
| 101 | |
| 102 EXPECT_EQ(0, memcmp(pixels.get(), new_pixels.get(), pixel_size)); | |
| 103 } | 89 } |
| 104 | 90 |
| 105 } // namespace | 91 } // namespace |
| 106 | 92 |
| 107 TEST(DisplayItemListTest, SerializeDisplayItemListSettings) { | 93 TEST(DisplayItemListTest, SerializeDisplayItemListSettings) { |
| 108 DisplayItemListSettings settings; | 94 DisplayItemListSettings settings; |
| 109 settings.use_cached_picture = false; | 95 settings.use_cached_picture = false; |
| 110 | 96 |
| 111 { | 97 { |
| 112 proto::DisplayItemListSettings proto; | 98 proto::DisplayItemListSettings proto; |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 // categories being traced). | 693 // categories being traced). |
| 708 list = new DisplayItemList(layer_rect, caching_settings, true); | 694 list = new DisplayItemList(layer_rect, caching_settings, true); |
| 709 item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect); | 695 item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect); |
| 710 item->SetNew(picture); | 696 item->SetNew(picture); |
| 711 list->Finalize(); | 697 list->Finalize(); |
| 712 memory_usage = list->ApproximateMemoryUsage(); | 698 memory_usage = list->ApproximateMemoryUsage(); |
| 713 EXPECT_EQ(static_cast<size_t>(0), memory_usage); | 699 EXPECT_EQ(static_cast<size_t>(0), memory_usage); |
| 714 } | 700 } |
| 715 | 701 |
| 716 } // namespace cc | 702 } // namespace cc |
| OLD | NEW |