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