| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" | 
| 6 | 6 | 
| 7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" | 
| 8 #include "cc/layers/picture_layer_impl.h" | 8 #include "cc/layers/picture_layer_impl.h" | 
| 9 #include "cc/resources/resource_update_queue.h" | 9 #include "cc/resources/resource_update_queue.h" | 
| 10 #include "cc/test/fake_layer_tree_host.h" | 10 #include "cc/test/fake_layer_tree_host.h" | 
|  | 11 #include "cc/test/fake_picture_layer.h" | 
| 11 #include "cc/test/fake_picture_layer_impl.h" | 12 #include "cc/test/fake_picture_layer_impl.h" | 
| 12 #include "cc/test/fake_proxy.h" | 13 #include "cc/test/fake_proxy.h" | 
| 13 #include "cc/test/impl_side_painting_settings.h" | 14 #include "cc/test/impl_side_painting_settings.h" | 
| 14 #include "cc/trees/occlusion_tracker.h" | 15 #include "cc/trees/occlusion_tracker.h" | 
| 15 #include "cc/trees/single_thread_proxy.h" | 16 #include "cc/trees/single_thread_proxy.h" | 
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" | 
| 17 | 18 | 
| 18 namespace cc { | 19 namespace cc { | 
| 19 namespace { | 20 namespace { | 
| 20 | 21 | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 104       FakeLayerTreeHost::Create(&host_client, settings); | 105       FakeLayerTreeHost::Create(&host_client, settings); | 
| 105   host->SetRootLayer(layer); | 106   host->SetRootLayer(layer); | 
| 106 | 107 | 
| 107   // Tile-grid is set according to its setting. | 108   // Tile-grid is set according to its setting. | 
| 108   gfx::Size size = | 109   gfx::Size size = | 
| 109       layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting(); | 110       layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting(); | 
| 110   EXPECT_EQ(size.width(), 123); | 111   EXPECT_EQ(size.width(), 123); | 
| 111   EXPECT_EQ(size.height(), 123); | 112   EXPECT_EQ(size.height(), 123); | 
| 112 } | 113 } | 
| 113 | 114 | 
|  | 115 // PicturePile uses the source frame number as a unit for measuring invalidation | 
|  | 116 // frequency. When a pile moves between compositors, the frame number increases | 
|  | 117 // non-monotonically. This executes that code path under this scenario allowing | 
|  | 118 // for the code to verify correctness with DCHECKs. | 
|  | 119 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 
|  | 120   LayerTreeSettings settings; | 
|  | 121   settings.single_thread_proxy_scheduler = false; | 
|  | 122 | 
|  | 123   FakeLayerTreeHostClient host_client1(FakeLayerTreeHostClient::DIRECT_3D); | 
|  | 124   FakeLayerTreeHostClient host_client2(FakeLayerTreeHostClient::DIRECT_3D); | 
|  | 125   scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 
|  | 126       new TestSharedBitmapManager()); | 
|  | 127 | 
|  | 128   MockContentLayerClient client; | 
|  | 129   scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(&client); | 
|  | 130 | 
|  | 131   scoped_ptr<LayerTreeHost> host1 = LayerTreeHost::CreateSingleThreaded( | 
|  | 132       &host_client1, &host_client1, shared_bitmap_manager.get(), nullptr, | 
|  | 133       settings, base::MessageLoopProxy::current(), nullptr); | 
|  | 134   host_client1.SetLayerTreeHost(host1.get()); | 
|  | 135 | 
|  | 136   scoped_ptr<LayerTreeHost> host2 = LayerTreeHost::CreateSingleThreaded( | 
|  | 137       &host_client2, &host_client2, shared_bitmap_manager.get(), nullptr, | 
|  | 138       settings, base::MessageLoopProxy::current(), nullptr); | 
|  | 139   host_client2.SetLayerTreeHost(host2.get()); | 
|  | 140 | 
|  | 141   // The PictureLayer is put in one LayerTreeHost. | 
|  | 142   host1->SetRootLayer(layer); | 
|  | 143   // Do a main frame, record the picture layers. | 
|  | 144   EXPECT_EQ(0u, layer->update_count()); | 
|  | 145   layer->SetNeedsDisplay(); | 
|  | 146   host1->Composite(base::TimeTicks::Now()); | 
|  | 147   EXPECT_EQ(1u, layer->update_count()); | 
|  | 148   EXPECT_EQ(1, host1->source_frame_number()); | 
|  | 149 | 
|  | 150   // The source frame number in |host1| is now higher than host2. | 
|  | 151   layer->SetNeedsDisplay(); | 
|  | 152   host1->Composite(base::TimeTicks::Now()); | 
|  | 153   EXPECT_EQ(2u, layer->update_count()); | 
|  | 154   EXPECT_EQ(2, host1->source_frame_number()); | 
|  | 155 | 
|  | 156   // Then moved to another LayerTreeHost. | 
|  | 157   host1->SetRootLayer(nullptr); | 
|  | 158   host2->SetRootLayer(layer); | 
|  | 159 | 
|  | 160   // Do a main frame, record the picture layers. The frame number has changed | 
|  | 161   // non-monotonically. | 
|  | 162   layer->SetNeedsDisplay(); | 
|  | 163   host2->Composite(base::TimeTicks::Now()); | 
|  | 164   EXPECT_EQ(3u, layer->update_count()); | 
|  | 165   EXPECT_EQ(1, host2->source_frame_number()); | 
|  | 166 } | 
|  | 167 | 
| 114 }  // namespace | 168 }  // namespace | 
| 115 }  // namespace cc | 169 }  // namespace cc | 
| OLD | NEW | 
|---|