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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } else { | 341 } else { |
342 window_->layer()->SetExternalTexture(NULL); | 342 window_->layer()->SetExternalTexture(NULL); |
343 } | 343 } |
344 #endif | 344 #endif |
345 } | 345 } |
346 | 346 |
347 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 347 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
348 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 348 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
349 int gpu_host_id) { | 349 int gpu_host_id) { |
350 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 350 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
351 current_surface_ = params.surface_id; | 351 current_surface_ = params.surface_handle; |
352 UpdateExternalTexture(); | 352 UpdateExternalTexture(); |
353 | 353 |
354 if (!window_->layer()->GetCompositor()) { | 354 if (!window_->layer()->GetCompositor()) { |
355 // We have no compositor, so we have no way to display the surface. | 355 // We have no compositor, so we have no way to display the surface. |
356 // Must still send the ACK. | 356 // Must still send the ACK. |
357 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); | 357 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); |
358 } else { | 358 } else { |
359 gfx::Size surface_size = | 359 gfx::Size surface_size = |
360 accelerated_surface_containers_[params.surface_id]->GetSize(); | 360 accelerated_surface_containers_[params.surface_handle]->GetSize(); |
361 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 361 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
362 | 362 |
363 // Add sending an ACK to the list of things to do OnCompositingEnded | 363 // Add sending an ACK to the list of things to do OnCompositingEnded |
364 on_compositing_ended_callbacks_.push_back( | 364 on_compositing_ended_callbacks_.push_back( |
365 base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers, | 365 base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers, |
366 params.route_id, gpu_host_id)); | 366 params.route_id, gpu_host_id)); |
367 ui::Compositor* compositor = window_->layer()->GetCompositor(); | 367 ui::Compositor* compositor = window_->layer()->GetCompositor(); |
368 if (!compositor->HasObserver(this)) | 368 if (!compositor->HasObserver(this)) |
369 compositor->AddObserver(this); | 369 compositor->AddObserver(this); |
370 } | 370 } |
371 #else | 371 #else |
372 NOTREACHED(); | 372 NOTREACHED(); |
373 #endif | 373 #endif |
374 } | 374 } |
375 | 375 |
376 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 376 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
377 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 377 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
378 int gpu_host_id) { | 378 int gpu_host_id) { |
379 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 379 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
380 current_surface_ = params.surface_id; | 380 current_surface_ = params.surface_handle; |
381 UpdateExternalTexture(); | 381 UpdateExternalTexture(); |
382 | 382 |
383 if (!window_->layer()->GetCompositor()) { | 383 if (!window_->layer()->GetCompositor()) { |
384 // We have no compositor, so we have no way to display the surface | 384 // We have no compositor, so we have no way to display the surface |
385 // Must still send the ACK | 385 // Must still send the ACK |
386 RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); | 386 RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); |
387 } else { | 387 } else { |
388 gfx::Size surface_size = | 388 gfx::Size surface_size = |
389 accelerated_surface_containers_[params.surface_id]->GetSize(); | 389 accelerated_surface_containers_[params.surface_handle]->GetSize(); |
390 | 390 |
391 // Co-ordinates come in OpenGL co-ordinate space. | 391 // Co-ordinates come in OpenGL co-ordinate space. |
392 // We need to convert to layer space. | 392 // We need to convert to layer space. |
393 window_->SchedulePaintInRect(gfx::Rect( | 393 window_->SchedulePaintInRect(gfx::Rect( |
394 params.x, | 394 params.x, |
395 surface_size.height() - params.y - params.height, | 395 surface_size.height() - params.y - params.height, |
396 params.width, | 396 params.width, |
397 params.height)); | 397 params.height)); |
398 | 398 |
399 // Add sending an ACK to the list of things to do OnCompositingEnded | 399 // Add sending an ACK to the list of things to do OnCompositingEnded |
400 on_compositing_ended_callbacks_.push_back( | 400 on_compositing_ended_callbacks_.push_back( |
401 base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer, | 401 base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer, |
402 params.route_id, gpu_host_id)); | 402 params.route_id, gpu_host_id)); |
403 ui::Compositor* compositor = window_->layer()->GetCompositor(); | 403 ui::Compositor* compositor = window_->layer()->GetCompositor(); |
404 if (!compositor->HasObserver(this)) | 404 if (!compositor->HasObserver(this)) |
405 compositor->AddObserver(this); | 405 compositor->AddObserver(this); |
406 } | 406 } |
407 #else | 407 #else |
408 NOTREACHED(); | 408 NOTREACHED(); |
409 #endif | 409 #endif |
410 } | 410 } |
411 | 411 |
412 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 412 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
413 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 413 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
414 int32 width, | 414 int32 width, |
415 int32 height, | 415 int32 height, |
416 uint64* surface_id, | 416 uint64* surface_handle, |
417 TransportDIB::Handle* surface_handle) { | 417 TransportDIB::Handle* shm_handle) { |
418 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( | 418 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( |
419 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); | 419 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); |
420 if (!surface->Initialize(surface_id)) { | 420 if (!surface->Initialize(surface_handle)) { |
421 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; | 421 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; |
422 return; | 422 return; |
423 } | 423 } |
424 *surface_handle = surface->Handle(); | 424 *shm_handle = surface->Handle(); |
425 | 425 |
426 accelerated_surface_containers_[*surface_id] = surface; | 426 accelerated_surface_containers_[*surface_handle] = surface; |
427 } | 427 } |
428 | 428 |
429 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { | 429 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( |
430 if (current_surface_ == surface_id) { | 430 uint64 surface_handle) { |
| 431 if (current_surface_ == surface_handle) { |
431 current_surface_ = gfx::kNullPluginWindow; | 432 current_surface_ = gfx::kNullPluginWindow; |
432 // Don't call UpdateExternalTexture: it's possible that a new surface with | 433 // Don't call UpdateExternalTexture: it's possible that a new surface with |
433 // the same ID will be re-created right away, in which case we don't want to | 434 // the same ID will be re-created right away, in which case we don't want to |
434 // flip back and forth. Instead wait until we got the accelerated | 435 // flip back and forth. Instead wait until we got the accelerated |
435 // compositing deactivation. | 436 // compositing deactivation. |
436 } | 437 } |
437 accelerated_surface_containers_.erase(surface_id); | 438 accelerated_surface_containers_.erase(surface_handle); |
438 } | 439 } |
439 #endif | 440 #endif |
440 | 441 |
441 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 442 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
442 RenderWidgetHostView::SetBackground(background); | 443 RenderWidgetHostView::SetBackground(background); |
443 host_->SetBackground(background); | 444 host_->SetBackground(background); |
444 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 445 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
445 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 446 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
446 #endif | 447 #endif |
447 } | 448 } |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 // static | 910 // static |
910 void RenderWidgetHostView::GetDefaultScreenInfo( | 911 void RenderWidgetHostView::GetDefaultScreenInfo( |
911 WebKit::WebScreenInfo* results) { | 912 WebKit::WebScreenInfo* results) { |
912 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 913 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
913 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 914 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
914 results->availableRect = results->rect; | 915 results->availableRect = results->rect; |
915 // TODO(derat): Don't hardcode this? | 916 // TODO(derat): Don't hardcode this? |
916 results->depth = 24; | 917 results->depth = 24; |
917 results->depthPerComponent = 8; | 918 results->depthPerComponent = 8; |
918 } | 919 } |
OLD | NEW |