| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 void ValidateDisplayItemListSerialization(const gfx::Size& layer_size, | 75 void ValidateDisplayItemListSerialization(const gfx::Size& layer_size, |
| 76 scoped_refptr<DisplayItemList> list) { | 76 scoped_refptr<DisplayItemList> list) { |
| 77 list->Finalize(); | 77 list->Finalize(); |
| 78 | 78 |
| 79 // Serialize and deserialize the DisplayItemList. | 79 // Serialize and deserialize the DisplayItemList. |
| 80 proto::DisplayItemList proto; | 80 proto::DisplayItemList proto; |
| 81 list->ToProtobuf(&proto); | 81 list->ToProtobuf(&proto); |
| 82 scoped_refptr<DisplayItemList> new_list = | 82 scoped_refptr<DisplayItemList> new_list = |
| 83 DisplayItemList::CreateFromProto(proto); | 83 DisplayItemList::CreateFromProto(proto); |
| 84 | 84 |
| 85 // Finalize the DisplayItemLists to perform raster. | 85 EXPECT_TRUE( |
| 86 new_list->Finalize(); | 86 AreDisplayListDrawingResultsSame(gfx::Rect(layer_size), list, new_list)); |
| 87 | |
| 88 const int pixel_size = 4 * layer_size.GetArea(); | |
| 89 | |
| 90 // Get the rendered contents of the old DisplayItemList. | |
| 91 scoped_ptr<unsigned char[]> pixels(new unsigned char[pixel_size]); | |
| 92 memset(pixels.get(), 0, pixel_size); | |
| 93 DrawDisplayList(pixels.get(), gfx::Rect(layer_size), list); | |
| 94 | |
| 95 // Get the rendered contents of the new DisplayItemList. | |
| 96 scoped_ptr<unsigned char[]> new_pixels(new unsigned char[pixel_size]); | |
| 97 memset(new_pixels.get(), 0, pixel_size); | |
| 98 DrawDisplayList(new_pixels.get(), gfx::Rect(layer_size), new_list); | |
| 99 | |
| 100 EXPECT_EQ(0, memcmp(pixels.get(), new_pixels.get(), pixel_size)); | |
| 101 } | 87 } |
| 102 | 88 |
| 103 } // namespace | 89 } // namespace |
| 104 | 90 |
| 105 TEST(DisplayItemListTest, SerializeDisplayItemListSettings) { | 91 TEST(DisplayItemListTest, SerializeDisplayItemListSettings) { |
| 106 DisplayItemListSettings settings; | 92 DisplayItemListSettings settings; |
| 107 settings.use_cached_picture = false; | 93 settings.use_cached_picture = false; |
| 108 | 94 |
| 109 { | 95 { |
| 110 proto::DisplayItemListSettings proto; | 96 proto::DisplayItemListSettings proto; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 // picture and items are retained (currently this only happens due to certain | 653 // picture and items are retained (currently this only happens due to certain |
| 668 // categories being traced). | 654 // categories being traced). |
| 669 list = new DisplayItemList(layer_rect, caching_settings, true); | 655 list = new DisplayItemList(layer_rect, caching_settings, true); |
| 670 list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture); | 656 list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture); |
| 671 list->Finalize(); | 657 list->Finalize(); |
| 672 memory_usage = list->ApproximateMemoryUsage(); | 658 memory_usage = list->ApproximateMemoryUsage(); |
| 673 EXPECT_EQ(static_cast<size_t>(0), memory_usage); | 659 EXPECT_EQ(static_cast<size_t>(0), memory_usage); |
| 674 } | 660 } |
| 675 | 661 |
| 676 } // namespace cc | 662 } // namespace cc |
| OLD | NEW |