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

Unified Diff: cc/layers/picture_layer_unittest.cc

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/tiled_layer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_unittest.cc
diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc
index afb60969e71391b49b68ef5b5f456cbfa67b2eb4..ab06bb01b81d9ffa09fd8237228043bf61e11b9d 100644
--- a/cc/layers/picture_layer_unittest.cc
+++ b/cc/layers/picture_layer_unittest.cc
@@ -8,6 +8,7 @@
#include "cc/layers/picture_layer_impl.h"
#include "cc/resources/resource_update_queue.h"
#include "cc/test/fake_layer_tree_host.h"
+#include "cc/test/fake_picture_layer.h"
#include "cc/test/fake_picture_layer_impl.h"
#include "cc/test/fake_proxy.h"
#include "cc/test/impl_side_painting_settings.h"
@@ -111,5 +112,58 @@ TEST(PictureLayerTest, UseTileGridSize) {
EXPECT_EQ(size.height(), 123);
}
+// PicturePile uses the source frame number as a unit for measuring invalidation
+// frequency. When a pile moves between compositors, the frame number increases
+// non-monotonically. This executes that code path under this scenario allowing
+// for the code to verify correctness with DCHECKs.
+TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) {
+ LayerTreeSettings settings;
+ settings.single_thread_proxy_scheduler = false;
+
+ FakeLayerTreeHostClient host_client1(FakeLayerTreeHostClient::DIRECT_3D);
+ FakeLayerTreeHostClient host_client2(FakeLayerTreeHostClient::DIRECT_3D);
+ scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
+ new TestSharedBitmapManager());
+
+ MockContentLayerClient client;
+ scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(&client);
+
+ scoped_ptr<LayerTreeHost> host1 = LayerTreeHost::CreateSingleThreaded(
+ &host_client1, &host_client1, shared_bitmap_manager.get(), nullptr,
+ settings, base::MessageLoopProxy::current(), nullptr);
+ host_client1.SetLayerTreeHost(host1.get());
+
+ scoped_ptr<LayerTreeHost> host2 = LayerTreeHost::CreateSingleThreaded(
+ &host_client2, &host_client2, shared_bitmap_manager.get(), nullptr,
+ settings, base::MessageLoopProxy::current(), nullptr);
+ host_client2.SetLayerTreeHost(host2.get());
+
+ // The PictureLayer is put in one LayerTreeHost.
+ host1->SetRootLayer(layer);
+ // Do a main frame, record the picture layers.
+ EXPECT_EQ(0u, layer->update_count());
+ layer->SetNeedsDisplay();
+ host1->Composite(base::TimeTicks::Now());
+ EXPECT_EQ(1u, layer->update_count());
+ EXPECT_EQ(1, host1->source_frame_number());
+
+ // The source frame number in |host1| is now higher than host2.
+ layer->SetNeedsDisplay();
+ host1->Composite(base::TimeTicks::Now());
+ EXPECT_EQ(2u, layer->update_count());
+ EXPECT_EQ(2, host1->source_frame_number());
+
+ // Then moved to another LayerTreeHost.
+ host1->SetRootLayer(nullptr);
+ host2->SetRootLayer(layer);
+
+ // Do a main frame, record the picture layers. The frame number has changed
+ // non-monotonically.
+ layer->SetNeedsDisplay();
+ host2->Composite(base::TimeTicks::Now());
+ EXPECT_EQ(3u, layer->update_count());
+ EXPECT_EQ(1, host2->source_frame_number());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/tiled_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698