OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 tooltip_ = tooltip_text; | 278 tooltip_ = tooltip_text; |
279 } | 279 } |
280 | 280 |
281 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( | 281 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( |
282 const gfx::Size& size) { | 282 const gfx::Size& size) { |
283 return new BackingStoreSkia(host_, size); | 283 return new BackingStoreSkia(host_, size); |
284 } | 284 } |
285 | 285 |
286 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { | 286 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { |
287 } | 287 } |
| 288 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
| 289 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 290 int gpu_host_id) { |
| 291 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| 292 window_->layer()->SetExternalTexture( |
| 293 accelerated_surface_containers_[params.surface_id]->GetTexture()); |
| 294 glFlush(); |
| 295 |
| 296 if (!window_->layer()->GetCompositor()) { |
| 297 // We have no compositor, so we have no way to display the surface |
| 298 // Must still send the ACK. |
| 299 AcknowledgeSwapBuffers(params.route_id, gpu_host_id); |
| 300 } else { |
| 301 window_->layer()->ScheduleDraw(); |
| 302 |
| 303 // Add sending an ACK to the list of things to do OnCompositingEnded |
| 304 on_compositing_ended_callbacks_.push_back( |
| 305 base::Bind(AcknowledgeSwapBuffers, params.route_id, gpu_host_id)); |
| 306 ui::Compositor* compositor = window_->layer()->GetCompositor(); |
| 307 if (!compositor->HasObserver(this)) |
| 308 compositor->AddObserver(this); |
| 309 } |
| 310 #else |
| 311 NOTREACHED(); |
| 312 #endif |
| 313 } |
288 | 314 |
289 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 315 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
290 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 316 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
291 int32 width, | 317 int32 width, |
292 int32 height, | 318 int32 height, |
293 uint64* surface_id, | 319 uint64* surface_id, |
294 TransportDIB::Handle* surface_handle) { | 320 TransportDIB::Handle* surface_handle) { |
295 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( | 321 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( |
296 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); | 322 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); |
297 if (!surface->Initialize(surface_id)) { | 323 if (!surface->Initialize(surface_id)) { |
298 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; | 324 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; |
299 return; | 325 return; |
300 } | 326 } |
301 *surface_handle = surface->Handle(); | 327 *surface_handle = surface->Handle(); |
302 | 328 |
303 accelerated_surface_containers_[*surface_id] = surface; | 329 accelerated_surface_containers_[*surface_id] = surface; |
304 } | 330 } |
305 | 331 |
306 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | |
307 uint64 surface_id, | |
308 int32 route_id, | |
309 int gpu_host_id) { | |
310 window_->layer()->SetExternalTexture( | |
311 accelerated_surface_containers_[surface_id]->GetTexture()); | |
312 glFlush(); | |
313 | |
314 if (!window_->layer()->GetCompositor()) { | |
315 // We have no compositor, so we have no way to display the surface | |
316 AcknowledgeSwapBuffers(route_id, gpu_host_id); // Must still send the ACK | |
317 } else { | |
318 window_->layer()->ScheduleDraw(); | |
319 | |
320 // Add sending an ACK to the list of things to do OnCompositingEnded | |
321 on_compositing_ended_callbacks_.push_back( | |
322 base::Bind(AcknowledgeSwapBuffers, route_id, gpu_host_id)); | |
323 ui::Compositor* compositor = window_->layer()->GetCompositor(); | |
324 if (!compositor->HasObserver(this)) | |
325 compositor->AddObserver(this); | |
326 } | |
327 } | |
328 | |
329 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { | 332 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { |
330 accelerated_surface_containers_.erase(surface_id); | 333 accelerated_surface_containers_.erase(surface_id); |
331 } | 334 } |
332 #endif | 335 #endif |
333 | 336 |
334 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 337 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
335 RenderWidgetHostView::SetBackground(background); | 338 RenderWidgetHostView::SetBackground(background); |
336 host_->SetBackground(background); | 339 host_->SetBackground(background); |
337 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 340 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
338 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 341 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // static | 544 // static |
542 void RenderWidgetHostView::GetDefaultScreenInfo( | 545 void RenderWidgetHostView::GetDefaultScreenInfo( |
543 WebKit::WebScreenInfo* results) { | 546 WebKit::WebScreenInfo* results) { |
544 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 547 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
545 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 548 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
546 results->availableRect = results->rect; | 549 results->availableRect = results->rect; |
547 // TODO(derat): Don't hardcode this? | 550 // TODO(derat): Don't hardcode this? |
548 results->depth = 24; | 551 results->depth = 24; |
549 results->depthPerComponent = 8; | 552 results->depthPerComponent = 8; |
550 } | 553 } |
OLD | NEW |