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

Side by Side Diff: cc/ipc/struct_traits_unittest.cc

Issue 2707243005: Discard compositor frames from unloaded web content (Closed)
Patch Set: Add default value for source ID in frame metadata Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "cc/input/selection.h" 7 #include "cc/input/selection.h"
8 #include "cc/ipc/copy_output_request_struct_traits.h" 8 #include "cc/ipc/copy_output_request_struct_traits.h"
9 #include "cc/ipc/traits_test_service.mojom.h" 9 #include "cc/ipc/traits_test_service.mojom.h"
10 #include "cc/output/copy_output_result.h" 10 #include "cc/output/copy_output_result.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 resource.id = tr_id; 233 resource.id = tr_id;
234 resource.format = tr_format; 234 resource.format = tr_format;
235 resource.filter = tr_filter; 235 resource.filter = tr_filter;
236 resource.size = tr_size; 236 resource.size = tr_size;
237 237
238 // CompositorFrameMetadata constants. 238 // CompositorFrameMetadata constants.
239 const float device_scale_factor = 2.6f; 239 const float device_scale_factor = 2.6f;
240 const gfx::Vector2dF root_scroll_offset(1234.5f, 6789.1f); 240 const gfx::Vector2dF root_scroll_offset(1234.5f, 6789.1f);
241 const float page_scale_factor = 1337.5f; 241 const float page_scale_factor = 1337.5f;
242 const gfx::SizeF scrollable_viewport_size(1337.7f, 1234.5f); 242 const gfx::SizeF scrollable_viewport_size(1337.7f, 1234.5f);
243 const uint32_t content_source_id = 3;
243 244
244 CompositorFrame input; 245 CompositorFrame input;
245 input.metadata.device_scale_factor = device_scale_factor; 246 input.metadata.device_scale_factor = device_scale_factor;
246 input.metadata.root_scroll_offset = root_scroll_offset; 247 input.metadata.root_scroll_offset = root_scroll_offset;
247 input.metadata.page_scale_factor = page_scale_factor; 248 input.metadata.page_scale_factor = page_scale_factor;
248 input.metadata.scrollable_viewport_size = scrollable_viewport_size; 249 input.metadata.scrollable_viewport_size = scrollable_viewport_size;
249 input.render_pass_list.push_back(std::move(render_pass)); 250 input.render_pass_list.push_back(std::move(render_pass));
250 input.resource_list.push_back(resource); 251 input.resource_list.push_back(resource);
252 input.metadata.content_source_id = content_source_id;
251 253
252 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 254 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
253 CompositorFrame output; 255 CompositorFrame output;
254 proxy->EchoCompositorFrame(std::move(input), &output); 256 proxy->EchoCompositorFrame(std::move(input), &output);
255 257
256 EXPECT_EQ(device_scale_factor, output.metadata.device_scale_factor); 258 EXPECT_EQ(device_scale_factor, output.metadata.device_scale_factor);
257 EXPECT_EQ(root_scroll_offset, output.metadata.root_scroll_offset); 259 EXPECT_EQ(root_scroll_offset, output.metadata.root_scroll_offset);
258 EXPECT_EQ(page_scale_factor, output.metadata.page_scale_factor); 260 EXPECT_EQ(page_scale_factor, output.metadata.page_scale_factor);
259 EXPECT_EQ(scrollable_viewport_size, output.metadata.scrollable_viewport_size); 261 EXPECT_EQ(scrollable_viewport_size, output.metadata.scrollable_viewport_size);
262 EXPECT_EQ(content_source_id, output.metadata.content_source_id);
260 263
261 ASSERT_EQ(1u, output.resource_list.size()); 264 ASSERT_EQ(1u, output.resource_list.size());
262 TransferableResource out_resource = output.resource_list[0]; 265 TransferableResource out_resource = output.resource_list[0];
263 EXPECT_EQ(tr_id, out_resource.id); 266 EXPECT_EQ(tr_id, out_resource.id);
264 EXPECT_EQ(tr_format, out_resource.format); 267 EXPECT_EQ(tr_format, out_resource.format);
265 EXPECT_EQ(tr_filter, out_resource.filter); 268 EXPECT_EQ(tr_filter, out_resource.filter);
266 EXPECT_EQ(tr_size, out_resource.size); 269 EXPECT_EQ(tr_size, out_resource.size);
267 270
268 EXPECT_EQ(1u, output.render_pass_list.size()); 271 EXPECT_EQ(1u, output.render_pass_list.size());
269 const RenderPass* out_render_pass = output.render_pass_list[0].get(); 272 const RenderPass* out_render_pass = output.render_pass_list[0].get();
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 EXPECT_EQ(u_plane_resource_id, out_quad->u_plane_resource_id()); 1189 EXPECT_EQ(u_plane_resource_id, out_quad->u_plane_resource_id());
1187 EXPECT_EQ(v_plane_resource_id, out_quad->v_plane_resource_id()); 1190 EXPECT_EQ(v_plane_resource_id, out_quad->v_plane_resource_id());
1188 EXPECT_EQ(a_plane_resource_id, out_quad->a_plane_resource_id()); 1191 EXPECT_EQ(a_plane_resource_id, out_quad->a_plane_resource_id());
1189 EXPECT_EQ(color_space, out_quad->color_space); 1192 EXPECT_EQ(color_space, out_quad->color_space);
1190 EXPECT_EQ(resource_offset, out_quad->resource_offset); 1193 EXPECT_EQ(resource_offset, out_quad->resource_offset);
1191 EXPECT_EQ(resource_multiplier, out_quad->resource_multiplier); 1194 EXPECT_EQ(resource_multiplier, out_quad->resource_multiplier);
1192 EXPECT_EQ(bits_per_channel, out_quad->bits_per_channel); 1195 EXPECT_EQ(bits_per_channel, out_quad->bits_per_channel);
1193 } 1196 }
1194 1197
1195 } // namespace cc 1198 } // namespace cc
OLDNEW
« no previous file with comments | « cc/ipc/compositor_frame_metadata_struct_traits.cc ('k') | cc/output/compositor_frame_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698