| OLD | NEW |
| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 cc::TextureMailbox mailbox; | 1292 cc::TextureMailbox mailbox; |
| 1293 scoped_ptr<cc::SingleReleaseCallback> callback; | 1293 scoped_ptr<cc::SingleReleaseCallback> callback; |
| 1294 framebuffer_holder_->GetMailbox(&mailbox, &callback); | 1294 framebuffer_holder_->GetMailbox(&mailbox, &callback); |
| 1295 window_->layer()->SetTextureMailbox(mailbox, | 1295 window_->layer()->SetTextureMailbox(mailbox, |
| 1296 callback.Pass(), | 1296 callback.Pass(), |
| 1297 last_swapped_surface_scale_factor_); | 1297 last_swapped_surface_scale_factor_); |
| 1298 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, | 1298 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, |
| 1299 mailbox.shared_memory_size()); | 1299 mailbox.shared_memory_size()); |
| 1300 CheckResizeLock(); | 1300 CheckResizeLock(); |
| 1301 } else { | 1301 } else { |
| 1302 window_->layer()->SetExternalTexture(NULL); | 1302 window_->layer()->SetShowPaintedContent(); |
| 1303 resize_lock_.reset(); | 1303 resize_lock_.reset(); |
| 1304 host_->WasResized(); | 1304 host_->WasResized(); |
| 1305 framebuffer_holder_ = NULL; | 1305 framebuffer_holder_ = NULL; |
| 1306 FrameMemoryManager::GetInstance()->RemoveFrame(this); | 1306 FrameMemoryManager::GetInstance()->RemoveFrame(this); |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1310 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| 1311 const gfx::Rect& surface_rect, | 1311 const gfx::Rect& surface_rect, |
| 1312 float surface_scale_factor, | 1312 float surface_scale_factor, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1423 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
| 1424 uint32 output_surface_id, | 1424 uint32 output_surface_id, |
| 1425 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1425 scoped_ptr<cc::DelegatedFrameData> frame_data, |
| 1426 float frame_device_scale_factor, | 1426 float frame_device_scale_factor, |
| 1427 const ui::LatencyInfo& latency_info) { | 1427 const ui::LatencyInfo& latency_info) { |
| 1428 gfx::Size frame_size; | 1428 gfx::Size frame_size; |
| 1429 gfx::Size frame_size_in_dip; | 1429 gfx::Size frame_size_in_dip; |
| 1430 gfx::Rect damage_rect; | 1430 gfx::Rect damage_rect; |
| 1431 gfx::Rect damage_rect_in_dip; | 1431 gfx::Rect damage_rect_in_dip; |
| 1432 | 1432 |
| 1433 if (!frame_data->render_pass_list.empty()) { | 1433 bool has_content = !frame_data->render_pass_list.empty(); |
| 1434 if (has_content) { |
| 1434 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 1435 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
| 1435 | 1436 |
| 1436 frame_size = root_pass->output_rect.size(); | 1437 frame_size = root_pass->output_rect.size(); |
| 1437 frame_size_in_dip = ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1438 frame_size_in_dip = ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 1438 | 1439 |
| 1439 damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); | 1440 damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); |
| 1440 damage_rect.Intersect(gfx::Rect(frame_size)); | 1441 damage_rect.Intersect(gfx::Rect(frame_size)); |
| 1441 damage_rect_in_dip = ConvertRectToDIP(frame_device_scale_factor, | 1442 damage_rect_in_dip = ConvertRectToDIP(frame_device_scale_factor, |
| 1442 damage_rect); | 1443 damage_rect); |
| 1443 } | 1444 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1465 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 1466 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
| 1466 root_pass->damage_rect = damage_rect; | 1467 root_pass->damage_rect = damage_rect; |
| 1467 } | 1468 } |
| 1468 | 1469 |
| 1469 if (output_surface_id != last_output_surface_id_) { | 1470 if (output_surface_id != last_output_surface_id_) { |
| 1470 // Resource ids are scoped by the output surface. | 1471 // Resource ids are scoped by the output surface. |
| 1471 // If the originating output surface doesn't match the last one, it | 1472 // If the originating output surface doesn't match the last one, it |
| 1472 // indicates the renderer's output surface may have been recreated, in which | 1473 // indicates the renderer's output surface may have been recreated, in which |
| 1473 // case we should recreate the DelegatedRendererLayer, to avoid matching | 1474 // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 1474 // resources from the old one with resources from the new one which would | 1475 // resources from the old one with resources from the new one which would |
| 1475 // have the same id. | 1476 // have the same id. Changing the layer to showing painted content destroys |
| 1476 window_->layer()->SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData>(), | 1477 // the DelegatedRendererLayer. |
| 1477 frame_size_in_dip); | 1478 window_->layer()->SetShowPaintedContent(); |
| 1478 last_output_surface_id_ = output_surface_id; | 1479 last_output_surface_id_ = output_surface_id; |
| 1479 } | 1480 } |
| 1480 window_->layer()->SetDelegatedFrame(frame_data.Pass(), frame_size_in_dip); | 1481 if (has_content) |
| 1482 window_->layer()->SetDelegatedFrame(frame_data.Pass(), frame_size_in_dip); |
| 1483 else |
| 1484 window_->layer()->SetShowPaintedContent(); |
| 1481 released_front_lock_ = NULL; | 1485 released_front_lock_ = NULL; |
| 1482 current_frame_size_ = frame_size_in_dip; | 1486 current_frame_size_ = frame_size_in_dip; |
| 1483 CheckResizeLock(); | 1487 CheckResizeLock(); |
| 1484 | 1488 |
| 1485 if (paint_observer_) | 1489 if (paint_observer_) |
| 1486 paint_observer_->OnUpdateCompositorContent(); | 1490 paint_observer_->OnUpdateCompositorContent(); |
| 1487 window_->SchedulePaintInRect(damage_rect_in_dip); | 1491 window_->SchedulePaintInRect(damage_rect_in_dip); |
| 1488 | 1492 |
| 1489 ui::Compositor* compositor = GetCompositor(); | 1493 ui::Compositor* compositor = GetCompositor(); |
| 1490 if (!compositor) { | 1494 if (!compositor) { |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 gl_helper && current_surface_.get()) { | 2589 gl_helper && current_surface_.get()) { |
| 2586 WebKit::WebGLId texture_id = | 2590 WebKit::WebGLId texture_id = |
| 2587 gl_helper->CopyTexture(current_surface_->PrepareTexture(), | 2591 gl_helper->CopyTexture(current_surface_->PrepareTexture(), |
| 2588 current_surface_->size()); | 2592 current_surface_->size()); |
| 2589 if (texture_id) { | 2593 if (texture_id) { |
| 2590 new_texture = factory->CreateOwnedTexture( | 2594 new_texture = factory->CreateOwnedTexture( |
| 2591 current_surface_->size(), | 2595 current_surface_->size(), |
| 2592 current_surface_->device_scale_factor(), texture_id); | 2596 current_surface_->device_scale_factor(), texture_id); |
| 2593 } | 2597 } |
| 2594 } | 2598 } |
| 2595 old_layer->SetExternalTexture(new_texture); | 2599 if (new_texture.get()) |
| 2596 new_layer->SetExternalTexture(old_texture); | 2600 old_layer->SetExternalTexture(new_texture.get()); |
| 2601 else |
| 2602 old_layer->SetShowPaintedContent(); |
| 2603 new_layer->SetExternalTexture(old_texture.get()); |
| 2597 } else if (old_mailbox.IsSharedMemory()) { | 2604 } else if (old_mailbox.IsSharedMemory()) { |
| 2598 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); | 2605 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); |
| 2599 const size_t size = old_mailbox.shared_memory_size_in_bytes(); | 2606 const size_t size = old_mailbox.shared_memory_size_in_bytes(); |
| 2600 | 2607 |
| 2601 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); | 2608 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); |
| 2602 new_buffer->CreateAndMapAnonymous(size); | 2609 new_buffer->CreateAndMapAnonymous(size); |
| 2603 | 2610 |
| 2604 if (old_buffer->memory() && new_buffer->memory()) { | 2611 if (old_buffer->memory() && new_buffer->memory()) { |
| 2605 memcpy(new_buffer->memory(), old_buffer->memory(), size); | 2612 memcpy(new_buffer->memory(), old_buffer->memory(), size); |
| 2606 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); | 2613 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3341 aura::client::GetCursorClient(window_->GetRootWindow()); | 3348 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 3342 if (cursor_client) | 3349 if (cursor_client) |
| 3343 cursor_client->RemoveObserver(this); | 3350 cursor_client->RemoveObserver(this); |
| 3344 | 3351 |
| 3345 event_filter_for_popup_exit_.reset(); | 3352 event_filter_for_popup_exit_.reset(); |
| 3346 window_->GetRootWindow()->RemoveRootWindowObserver(this); | 3353 window_->GetRootWindow()->RemoveRootWindowObserver(this); |
| 3347 host_->ParentChanged(0); | 3354 host_->ParentChanged(0); |
| 3348 ui::Compositor* compositor = GetCompositor(); | 3355 ui::Compositor* compositor = GetCompositor(); |
| 3349 // We can't get notification for commits after this point, which would | 3356 // We can't get notification for commits after this point, which would |
| 3350 // guarantee that the compositor isn't using an old texture any more, so | 3357 // guarantee that the compositor isn't using an old texture any more, so |
| 3351 // instead we force the texture to NULL which synchronizes with the compositor | 3358 // instead we force the layer to stop using any external resources which |
| 3352 // thread, and makes it safe to run the callback. | 3359 // synchronizes with the compositor thread, and makes it safe to run the |
| 3353 window_->layer()->SetExternalTexture(NULL); | 3360 // callback. |
| 3361 window_->layer()->SetShowPaintedContent(); |
| 3354 RunOnCommitCallbacks(); | 3362 RunOnCommitCallbacks(); |
| 3355 resize_lock_.reset(); | 3363 resize_lock_.reset(); |
| 3356 host_->WasResized(); | 3364 host_->WasResized(); |
| 3357 if (compositor && compositor->HasObserver(this)) | 3365 if (compositor && compositor->HasObserver(this)) |
| 3358 compositor->RemoveObserver(this); | 3366 compositor->RemoveObserver(this); |
| 3359 } | 3367 } |
| 3360 | 3368 |
| 3361 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { | 3369 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { |
| 3362 aura::RootWindow* root_window = window_->GetRootWindow(); | 3370 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 3363 return root_window ? root_window->compositor() : NULL; | 3371 return root_window ? root_window->compositor() : NULL; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3377 RenderWidgetHost* widget) { | 3385 RenderWidgetHost* widget) { |
| 3378 return new RenderWidgetHostViewAura(widget); | 3386 return new RenderWidgetHostViewAura(widget); |
| 3379 } | 3387 } |
| 3380 | 3388 |
| 3381 // static | 3389 // static |
| 3382 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3390 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3383 GetScreenInfoForWindow(results, NULL); | 3391 GetScreenInfoForWindow(results, NULL); |
| 3384 } | 3392 } |
| 3385 | 3393 |
| 3386 } // namespace content | 3394 } // namespace content |
| OLD | NEW |