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