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