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 | |
306 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 278 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
307 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 279 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
308 int32 width, | 280 int32 width, |
309 int32 height, | 281 int32 height, |
310 uint64* surface_id, | 282 uint64* surface_id, |
311 TransportDIB::Handle* surface_handle) { | 283 TransportDIB::Handle* surface_handle) { |
312 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( | 284 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( |
313 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); | 285 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); |
314 if (!surface->Initialize(surface_id)) { | 286 if (!surface->Initialize(surface_id)) { |
315 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; | 287 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; |
316 return; | 288 return; |
317 } | 289 } |
318 *surface_handle = surface->Handle(); | 290 *surface_handle = surface->Handle(); |
319 | 291 |
320 accelerated_surface_containers_[*surface_id] = surface; | 292 accelerated_surface_containers_[*surface_id] = surface; |
321 } | 293 } |
322 | 294 |
| 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 |
323 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { | 320 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { |
324 accelerated_surface_containers_.erase(surface_id); | 321 accelerated_surface_containers_.erase(surface_id); |
325 } | 322 } |
326 #endif | 323 #endif |
327 | 324 |
328 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 325 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
329 RenderWidgetHostView::SetBackground(background); | 326 RenderWidgetHostView::SetBackground(background); |
330 host_->SetBackground(background); | 327 host_->SetBackground(background); |
331 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 328 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
332 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 329 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 // static | 535 // static |
539 void RenderWidgetHostView::GetDefaultScreenInfo( | 536 void RenderWidgetHostView::GetDefaultScreenInfo( |
540 WebKit::WebScreenInfo* results) { | 537 WebKit::WebScreenInfo* results) { |
541 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 538 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
542 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 539 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
543 results->availableRect = results->rect; | 540 results->availableRect = results->rect; |
544 // TODO(derat): Don't hardcode this? | 541 // TODO(derat): Don't hardcode this? |
545 results->depth = 24; | 542 results->depth = 24; |
546 results->depthPerComponent = 8; | 543 results->depthPerComponent = 8; |
547 } | 544 } |
OLD | NEW |