Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 9194005: gpu: reference target surfaces through a globally unique surface id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix more tests Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } else { 339 } else {
340 window_->layer()->SetExternalTexture(NULL); 340 window_->layer()->SetExternalTexture(NULL);
341 } 341 }
342 #endif 342 #endif
343 } 343 }
344 344
345 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 345 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
346 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 346 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
347 int gpu_host_id) { 347 int gpu_host_id) {
348 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 348 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
349 current_surface_ = params.surface_id; 349 current_surface_ = params.surface_handle;
350 UpdateExternalTexture(); 350 UpdateExternalTexture();
351 351
352 if (!window_->layer()->GetCompositor()) { 352 if (!window_->layer()->GetCompositor()) {
353 // We have no compositor, so we have no way to display the surface. 353 // We have no compositor, so we have no way to display the surface.
354 // Must still send the ACK. 354 // Must still send the ACK.
355 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); 355 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id);
356 } else { 356 } else {
357 gfx::Size surface_size = 357 gfx::Size surface_size =
358 accelerated_surface_containers_[params.surface_id]->GetSize(); 358 accelerated_surface_containers_[params.surface_handle]->GetSize();
359 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 359 window_->SchedulePaintInRect(gfx::Rect(surface_size));
360 360
361 // Add sending an ACK to the list of things to do OnCompositingEnded 361 // Add sending an ACK to the list of things to do OnCompositingEnded
362 on_compositing_ended_callbacks_.push_back( 362 on_compositing_ended_callbacks_.push_back(
363 base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers, 363 base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers,
364 params.route_id, gpu_host_id)); 364 params.route_id, gpu_host_id));
365 ui::Compositor* compositor = window_->layer()->GetCompositor(); 365 ui::Compositor* compositor = window_->layer()->GetCompositor();
366 if (!compositor->HasObserver(this)) 366 if (!compositor->HasObserver(this))
367 compositor->AddObserver(this); 367 compositor->AddObserver(this);
368 } 368 }
369 #else 369 #else
370 NOTREACHED(); 370 NOTREACHED();
371 #endif 371 #endif
372 } 372 }
373 373
374 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 374 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
375 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 375 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
376 int gpu_host_id) { 376 int gpu_host_id) {
377 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 377 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
378 current_surface_ = params.surface_id; 378 current_surface_ = params.surface_handle;
379 UpdateExternalTexture(); 379 UpdateExternalTexture();
380 380
381 if (!window_->layer()->GetCompositor()) { 381 if (!window_->layer()->GetCompositor()) {
382 // We have no compositor, so we have no way to display the surface 382 // We have no compositor, so we have no way to display the surface
383 // Must still send the ACK 383 // Must still send the ACK
384 RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); 384 RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id);
385 } else { 385 } else {
386 gfx::Size surface_size = 386 gfx::Size surface_size =
387 accelerated_surface_containers_[params.surface_id]->GetSize(); 387 accelerated_surface_containers_[params.surface_handle]->GetSize();
388 388
389 // Co-ordinates come in OpenGL co-ordinate space. 389 // Co-ordinates come in OpenGL co-ordinate space.
390 // We need to convert to layer space. 390 // We need to convert to layer space.
391 window_->SchedulePaintInRect(gfx::Rect( 391 window_->SchedulePaintInRect(gfx::Rect(
392 params.x, 392 params.x,
393 surface_size.height() - params.y - params.height, 393 surface_size.height() - params.y - params.height,
394 params.width, 394 params.width,
395 params.height)); 395 params.height));
396 396
397 // Add sending an ACK to the list of things to do OnCompositingEnded 397 // Add sending an ACK to the list of things to do OnCompositingEnded
398 on_compositing_ended_callbacks_.push_back( 398 on_compositing_ended_callbacks_.push_back(
399 base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer, 399 base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer,
400 params.route_id, gpu_host_id)); 400 params.route_id, gpu_host_id));
401 ui::Compositor* compositor = window_->layer()->GetCompositor(); 401 ui::Compositor* compositor = window_->layer()->GetCompositor();
402 if (!compositor->HasObserver(this)) 402 if (!compositor->HasObserver(this))
403 compositor->AddObserver(this); 403 compositor->AddObserver(this);
404 } 404 }
405 #else 405 #else
406 NOTREACHED(); 406 NOTREACHED();
407 #endif 407 #endif
408 } 408 }
409 409
410 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 410 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
411 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( 411 void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
412 int32 width, 412 int32 width,
413 int32 height, 413 int32 height,
414 uint64* surface_id, 414 uint64* surface_handle,
415 TransportDIB::Handle* surface_handle) { 415 TransportDIB::Handle* shm_handle) {
416 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( 416 scoped_refptr<AcceleratedSurfaceContainerLinux> surface(
417 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); 417 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height)));
418 if (!surface->Initialize(surface_id)) { 418 if (!surface->Initialize(surface_handle)) {
419 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; 419 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer";
420 return; 420 return;
421 } 421 }
422 *surface_handle = surface->Handle(); 422 *shm_handle = surface->Handle();
423 423
424 accelerated_surface_containers_[*surface_id] = surface; 424 accelerated_surface_containers_[*surface_handle] = surface;
425 } 425 }
426 426
427 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { 427 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(
428 if (current_surface_ == surface_id) { 428 uint64 surface_handle) {
429 if (current_surface_ == surface_handle) {
429 current_surface_ = gfx::kNullPluginWindow; 430 current_surface_ = gfx::kNullPluginWindow;
430 // Don't call UpdateExternalTexture: it's possible that a new surface with 431 // Don't call UpdateExternalTexture: it's possible that a new surface with
431 // the same ID will be re-created right away, in which case we don't want to 432 // the same ID will be re-created right away, in which case we don't want to
432 // flip back and forth. Instead wait until we got the accelerated 433 // flip back and forth. Instead wait until we got the accelerated
433 // compositing deactivation. 434 // compositing deactivation.
434 } 435 }
435 accelerated_surface_containers_.erase(surface_id); 436 accelerated_surface_containers_.erase(surface_handle);
436 } 437 }
437 #endif 438 #endif
438 439
439 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { 440 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
440 RenderWidgetHostView::SetBackground(background); 441 RenderWidgetHostView::SetBackground(background);
441 host_->SetBackground(background); 442 host_->SetBackground(background);
442 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 443 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
443 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 444 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
444 #endif 445 #endif
445 } 446 }
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 // static 918 // static
918 void RenderWidgetHostView::GetDefaultScreenInfo( 919 void RenderWidgetHostView::GetDefaultScreenInfo(
919 WebKit::WebScreenInfo* results) { 920 WebKit::WebScreenInfo* results) {
920 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); 921 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize();
921 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); 922 results->rect = WebKit::WebRect(0, 0, size.width(), size.height());
922 results->availableRect = results->rect; 923 results->availableRect = results->rect;
923 // TODO(derat): Don't hardcode this? 924 // TODO(derat): Don't hardcode this?
924 results->depth = 24; 925 results->depth = 24;
925 results->depthPerComponent = 8; 926 results->depthPerComponent = 8;
926 } 927 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698