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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2803913004: cc: Introduce embedded_surfaces in metadata for surface Ids in draw quads (Closed)
Patch Set: Addressed Dana's comments Created 3 years, 8 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/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 5350b1a3c6eb30cbd23645137a683c5fa00f81d4..a400b8b39b5eb331a27ef200a3a94908a2e848e0 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -30,6 +30,7 @@
#include "cc/layers/render_surface_impl.h"
#include "cc/layers/solid_color_layer_impl.h"
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
+#include "cc/layers/surface_layer_impl.h"
#include "cc/layers/texture_layer_impl.h"
#include "cc/layers/video_layer_impl.h"
#include "cc/layers/viewport.h"
@@ -93,6 +94,12 @@ using media::VideoFrame;
namespace cc {
namespace {
+SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) {
+ return SurfaceId(
+ frame_sink_id,
+ LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u)));
+}
+
struct TestFrameData : public LayerTreeHostImpl::FrameData {
TestFrameData() {
// Set ack to something valid, so DCHECKs don't complain.
@@ -3481,6 +3488,43 @@ TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
SetupMouseMoveAtWithDeviceScale(2.f);
}
+// This test verifies that only SurfaceLayers in the viewport are included
+// in CompositorFrameMetadata's |embedded_surfaces|.
+TEST_F(LayerTreeHostImplTest, EmbeddedSurfacesInMetadata) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
+
+ std::vector<SurfaceId> children = {MakeSurfaceId(FrameSinkId(1, 1), 1),
+ MakeSurfaceId(FrameSinkId(2, 2), 2),
+ MakeSurfaceId(FrameSinkId(3, 3), 3)};
+ for (size_t i = 0; i < children.size(); ++i) {
+ std::unique_ptr<SurfaceLayerImpl> child =
+ SurfaceLayerImpl::Create(host_impl_->active_tree(), i + 6);
+ child->SetPosition(gfx::PointF(25.f * i, 0.f));
+ child->SetBounds(gfx::Size(1, 1));
+ child->SetDrawsContent(true);
+ child->SetPrimarySurfaceInfo(
+ SurfaceInfo(children[i], 1.f /* device_scale_factor */,
+ gfx::Size(10, 10) /* size_in_pixels */));
+ root->test_properties()->AddChild(std::move(child));
+ }
+
+ host_impl_->active_tree()->BuildPropertyTreesForTesting();
+ DrawFrame();
+
+ FakeCompositorFrameSink* fake_compositor_frame_sink =
+ static_cast<FakeCompositorFrameSink*>(
+ host_impl_->compositor_frame_sink());
+ const CompositorFrameMetadata& metadata =
+ fake_compositor_frame_sink->last_sent_frame()->metadata;
+ EXPECT_THAT(metadata.embedded_surfaces,
+ testing::UnorderedElementsAre(children[0], children[1]));
+ EXPECT_THAT(
+ metadata.referenced_surfaces,
+ testing::UnorderedElementsAre(children[0], children[1], children[2]));
+}
+
TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->SetViewportSize(gfx::Size(50, 50));
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698