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 "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 gfx::Rect view_rect(view_size); | 231 gfx::Rect view_rect(view_size); |
232 float scale_factor = 1.f; | 232 float scale_factor = 1.f; |
233 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); | 233 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); |
234 | 234 |
235 ASSERT_TRUE(browser_plugin_guest_); | 235 ASSERT_TRUE(browser_plugin_guest_); |
236 | 236 |
237 view_->SetSize(view_size); | 237 view_->SetSize(view_size); |
238 view_->Show(); | 238 view_->Show(); |
239 | 239 |
240 browser_plugin_guest_->set_attached(true); | 240 browser_plugin_guest_->set_attached(true); |
241 view_->OnSwapCompositorFrame( | 241 view_->SubmitCompositorFrame( |
242 0, local_surface_id, | 242 local_surface_id, |
243 CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 243 CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
244 | 244 |
245 cc::SurfaceId id = GetSurfaceId(); | 245 cc::SurfaceId id = GetSurfaceId(); |
246 | 246 |
247 EXPECT_TRUE(id.is_valid()); | 247 EXPECT_TRUE(id.is_valid()); |
248 | 248 |
249 #if !defined(OS_ANDROID) | 249 #if !defined(OS_ANDROID) |
250 cc::SurfaceManager* manager = ImageTransportFactory::GetInstance() | 250 cc::SurfaceManager* manager = ImageTransportFactory::GetInstance() |
251 ->GetContextFactoryPrivate() | 251 ->GetContextFactoryPrivate() |
252 ->GetSurfaceManager(); | 252 ->GetSurfaceManager(); |
253 cc::Surface* surface = manager->GetSurfaceForId(id); | 253 cc::Surface* surface = manager->GetSurfaceForId(id); |
254 EXPECT_TRUE(surface); | 254 EXPECT_TRUE(surface); |
255 // There should be a SurfaceSequence created by the RWHVGuest. | 255 // There should be a SurfaceSequence created by the RWHVGuest. |
256 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); | 256 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); |
257 #endif | 257 #endif |
258 // Surface ID should have been passed to BrowserPluginGuest to | 258 // Surface ID should have been passed to BrowserPluginGuest to |
259 // be sent to the embedding renderer. | 259 // be sent to the embedding renderer. |
260 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size), | 260 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size), |
261 browser_plugin_guest_->last_surface_info_); | 261 browser_plugin_guest_->last_surface_info_); |
262 | 262 |
263 browser_plugin_guest_->ResetTestData(); | 263 browser_plugin_guest_->ResetTestData(); |
264 browser_plugin_guest_->set_has_attached_since_surface_set(true); | 264 browser_plugin_guest_->set_has_attached_since_surface_set(true); |
265 | 265 |
266 view_->OnSwapCompositorFrame( | 266 view_->SubmitCompositorFrame( |
267 0, local_surface_id, | 267 local_surface_id, |
268 CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 268 CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
269 | 269 |
270 // Since we have not changed the frame size and scale factor, the same surface | 270 // Since we have not changed the frame size and scale factor, the same surface |
271 // id must be used. | 271 // id must be used. |
272 DCHECK_EQ(id, GetSurfaceId()); | 272 DCHECK_EQ(id, GetSurfaceId()); |
273 | 273 |
274 #if !defined(OS_ANDROID) | 274 #if !defined(OS_ANDROID) |
275 surface = manager->GetSurfaceForId(id); | 275 surface = manager->GetSurfaceForId(id); |
276 EXPECT_TRUE(surface); | 276 EXPECT_TRUE(surface); |
277 // Another SurfaceSequence should be created by the RWHVGuest when sending | 277 // Another SurfaceSequence should be created by the RWHVGuest when sending |
278 // SurfaceInfo to the embedder. | 278 // SurfaceInfo to the embedder. |
279 EXPECT_EQ(2u, surface->GetDestructionDependencyCount()); | 279 EXPECT_EQ(2u, surface->GetDestructionDependencyCount()); |
280 #endif | 280 #endif |
281 // Surface ID should have been passed to BrowserPluginGuest to | 281 // Surface ID should have been passed to BrowserPluginGuest to |
282 // be sent to the embedding renderer. | 282 // be sent to the embedding renderer. |
283 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size), | 283 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size), |
284 browser_plugin_guest_->last_surface_info_); | 284 browser_plugin_guest_->last_surface_info_); |
285 | 285 |
286 browser_plugin_guest_->set_attached(false); | 286 browser_plugin_guest_->set_attached(false); |
287 browser_plugin_guest_->ResetTestData(); | 287 browser_plugin_guest_->ResetTestData(); |
288 | 288 |
289 view_->OnSwapCompositorFrame( | 289 view_->SubmitCompositorFrame( |
290 0, local_surface_id, | 290 local_surface_id, |
291 CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 291 CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
292 // Since guest is not attached, the CompositorFrame must be processed but the | 292 // Since guest is not attached, the CompositorFrame must be processed but the |
293 // frame must be evicted to return the resources immediately. | 293 // frame must be evicted to return the resources immediately. |
294 EXPECT_FALSE(view_->has_frame()); | 294 EXPECT_FALSE(view_->has_frame()); |
295 } | 295 } |
296 | 296 |
297 } // namespace content | 297 } // namespace content |
OLD | NEW |