OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/renderer_host/backing_store_skia.h" | 8 #include "content/browser/renderer_host/backing_store_skia.h" |
9 #include "content/browser/renderer_host/render_widget_host.h" | 9 #include "content/browser/renderer_host/render_widget_host.h" |
10 #include "content/browser/renderer_host/web_input_event_aura.h" | 10 #include "content/browser/renderer_host/web_input_event_aura.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 345 } |
346 | 346 |
347 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { | 347 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { |
348 UpdateExternalTexture(); | 348 UpdateExternalTexture(); |
349 } | 349 } |
350 | 350 |
351 void RenderWidgetHostViewAura::UpdateExternalTexture() { | 351 void RenderWidgetHostViewAura::UpdateExternalTexture() { |
352 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 352 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
353 if (current_surface_ != gfx::kNullPluginWindow && | 353 if (current_surface_ != gfx::kNullPluginWindow && |
354 host_->is_accelerated_compositing_active()) { | 354 host_->is_accelerated_compositing_active()) { |
355 window_->SetExternalTexture( | 355 AcceleratedSurfaceContainerLinux* container = |
356 accelerated_surface_containers_[current_surface_]->GetTexture()); | 356 accelerated_surface_containers_[current_surface_]; |
| 357 if (container) |
| 358 container->Update(); |
| 359 window_->SetExternalTexture(container); |
357 glFlush(); | 360 glFlush(); |
358 } else { | 361 } else { |
359 window_->SetExternalTexture(NULL); | 362 window_->SetExternalTexture(NULL); |
360 } | 363 } |
361 #endif | 364 #endif |
362 } | 365 } |
363 | 366 |
364 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 367 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
365 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 368 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
366 int gpu_host_id) { | 369 int gpu_host_id) { |
367 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 370 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
368 current_surface_ = params.surface_handle; | 371 current_surface_ = params.surface_handle; |
369 UpdateExternalTexture(); | 372 UpdateExternalTexture(); |
370 | 373 |
371 if (!aura::RootWindow::GetInstance()->compositor()) { | 374 if (!aura::RootWindow::GetInstance()->compositor()) { |
372 // We have no compositor, so we have no way to display the surface. | 375 // We have no compositor, so we have no way to display the surface. |
373 // Must still send the ACK. | 376 // Must still send the ACK. |
374 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); | 377 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); |
375 } else { | 378 } else { |
376 gfx::Size surface_size = | 379 gfx::Size surface_size = |
377 accelerated_surface_containers_[params.surface_handle]->GetSize(); | 380 accelerated_surface_containers_[params.surface_handle]->size(); |
378 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 381 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
379 | 382 |
380 // Add sending an ACK to the list of things to do OnCompositingEnded | 383 // Add sending an ACK to the list of things to do OnCompositingEnded |
381 on_compositing_ended_callbacks_.push_back( | 384 on_compositing_ended_callbacks_.push_back( |
382 base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers, | 385 base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers, |
383 params.route_id, gpu_host_id)); | 386 params.route_id, gpu_host_id)); |
384 ui::Compositor* compositor = aura::RootWindow::GetInstance()->compositor(); | 387 ui::Compositor* compositor = aura::RootWindow::GetInstance()->compositor(); |
385 if (!compositor->HasObserver(this)) | 388 if (!compositor->HasObserver(this)) |
386 compositor->AddObserver(this); | 389 compositor->AddObserver(this); |
387 } | 390 } |
388 #else | 391 #else |
389 NOTREACHED(); | 392 NOTREACHED(); |
390 #endif | 393 #endif |
391 } | 394 } |
392 | 395 |
393 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 396 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
394 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 397 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
395 int gpu_host_id) { | 398 int gpu_host_id) { |
396 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 399 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
397 current_surface_ = params.surface_handle; | 400 current_surface_ = params.surface_handle; |
398 UpdateExternalTexture(); | 401 UpdateExternalTexture(); |
399 | 402 |
400 if (!aura::RootWindow::GetInstance()->compositor()) { | 403 if (!aura::RootWindow::GetInstance()->compositor()) { |
401 // We have no compositor, so we have no way to display the surface | 404 // We have no compositor, so we have no way to display the surface |
402 // Must still send the ACK | 405 // Must still send the ACK |
403 RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); | 406 RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); |
404 } else { | 407 } else { |
405 gfx::Size surface_size = | 408 gfx::Size surface_size = |
406 accelerated_surface_containers_[params.surface_handle]->GetSize(); | 409 accelerated_surface_containers_[params.surface_handle]->size(); |
407 | 410 |
408 // Co-ordinates come in OpenGL co-ordinate space. | 411 // Co-ordinates come in OpenGL co-ordinate space. |
409 // We need to convert to layer space. | 412 // We need to convert to layer space. |
410 window_->SchedulePaintInRect(gfx::Rect( | 413 window_->SchedulePaintInRect(gfx::Rect( |
411 params.x, | 414 params.x, |
412 surface_size.height() - params.y - params.height, | 415 surface_size.height() - params.y - params.height, |
413 params.width, | 416 params.width, |
414 params.height)); | 417 params.height)); |
415 | 418 |
416 // Add sending an ACK to the list of things to do OnCompositingEnded | 419 // Add sending an ACK to the list of things to do OnCompositingEnded |
417 on_compositing_ended_callbacks_.push_back( | 420 on_compositing_ended_callbacks_.push_back( |
418 base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer, | 421 base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer, |
419 params.route_id, gpu_host_id)); | 422 params.route_id, gpu_host_id)); |
420 ui::Compositor* compositor = aura::RootWindow::GetInstance()->compositor(); | 423 ui::Compositor* compositor = aura::RootWindow::GetInstance()->compositor(); |
421 if (!compositor->HasObserver(this)) | 424 if (!compositor->HasObserver(this)) |
422 compositor->AddObserver(this); | 425 compositor->AddObserver(this); |
423 } | 426 } |
424 #else | 427 #else |
425 NOTREACHED(); | 428 NOTREACHED(); |
426 #endif | 429 #endif |
427 } | 430 } |
428 | 431 |
429 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 432 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
430 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 433 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
431 int32 width, | 434 int32 width, |
432 int32 height, | 435 int32 height, |
433 uint64* surface_handle, | 436 uint64* surface_handle, |
434 TransportDIB::Handle* shm_handle) { | 437 TransportDIB::Handle* shm_handle) { |
435 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( | 438 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( |
436 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); | 439 new AcceleratedSurfaceContainerLinux(gfx::Size(width, height))); |
437 if (!surface->Initialize(surface_handle)) { | 440 if (!surface->Initialize(surface_handle)) { |
438 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; | 441 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; |
439 return; | 442 return; |
440 } | 443 } |
441 *shm_handle = surface->Handle(); | 444 *shm_handle = surface->Handle(); |
442 | 445 |
443 accelerated_surface_containers_[*surface_handle] = surface; | 446 accelerated_surface_containers_[*surface_handle] = surface; |
444 } | 447 } |
445 | 448 |
446 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( | 449 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // static | 1061 // static |
1059 void RenderWidgetHostView::GetDefaultScreenInfo( | 1062 void RenderWidgetHostView::GetDefaultScreenInfo( |
1060 WebKit::WebScreenInfo* results) { | 1063 WebKit::WebScreenInfo* results) { |
1061 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 1064 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
1062 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 1065 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
1063 results->availableRect = results->rect; | 1066 results->availableRect = results->rect; |
1064 // TODO(derat): Don't hardcode this? | 1067 // TODO(derat): Don't hardcode this? |
1065 results->depth = 24; | 1068 results->depth = 24; |
1066 results->depthPerComponent = 8; | 1069 results->depthPerComponent = 8; |
1067 } | 1070 } |
OLD | NEW |