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 } | |
314 | 288 |
315 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 289 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
316 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 290 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
317 int32 width, | 291 int32 width, |
318 int32 height, | 292 int32 height, |
319 uint64* surface_id, | 293 uint64* surface_id, |
320 TransportDIB::Handle* surface_handle) { | 294 TransportDIB::Handle* surface_handle) { |
321 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( | 295 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( |
322 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); | 296 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); |
323 if (!surface->Initialize(surface_id)) { | 297 if (!surface->Initialize(surface_id)) { |
324 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; | 298 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; |
325 return; | 299 return; |
326 } | 300 } |
327 *surface_handle = surface->Handle(); | 301 *surface_handle = surface->Handle(); |
328 | 302 |
329 accelerated_surface_containers_[*surface_id] = surface; | 303 accelerated_surface_containers_[*surface_id] = surface; |
330 } | 304 } |
331 | 305 |
| 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 |
332 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { | 329 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { |
333 accelerated_surface_containers_.erase(surface_id); | 330 accelerated_surface_containers_.erase(surface_id); |
334 } | 331 } |
335 #endif | 332 #endif |
336 | 333 |
337 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 334 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
338 RenderWidgetHostView::SetBackground(background); | 335 RenderWidgetHostView::SetBackground(background); |
339 host_->SetBackground(background); | 336 host_->SetBackground(background); |
340 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 337 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
341 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 338 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 // static | 544 // static |
548 void RenderWidgetHostView::GetDefaultScreenInfo( | 545 void RenderWidgetHostView::GetDefaultScreenInfo( |
549 WebKit::WebScreenInfo* results) { | 546 WebKit::WebScreenInfo* results) { |
550 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 547 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
551 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 548 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
552 results->availableRect = results->rect; | 549 results->availableRect = results->rect; |
553 // TODO(derat): Don't hardcode this? | 550 // TODO(derat): Don't hardcode this? |
554 results->depth = 24; | 551 results->depth = 24; |
555 results->depthPerComponent = 8; | 552 results->depthPerComponent = 8; |
556 } | 553 } |
OLD | NEW |