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_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 WasHidden(); | 400 WasHidden(); |
401 } | 401 } |
402 | 402 |
403 bool RenderWidgetHostViewAndroid::IsShowing() { | 403 bool RenderWidgetHostViewAndroid::IsShowing() { |
404 // ContentViewCoreImpl represents the native side of the Java | 404 // ContentViewCoreImpl represents the native side of the Java |
405 // ContentViewCore. It being NULL means that it is not attached | 405 // ContentViewCore. It being NULL means that it is not attached |
406 // to the View system yet, so we treat this RWHVA as hidden. | 406 // to the View system yet, so we treat this RWHVA as hidden. |
407 return is_showing_ && content_view_core_; | 407 return is_showing_ && content_view_core_; |
408 } | 408 } |
409 | 409 |
410 void RenderWidgetHostViewAndroid::LockResources() { | 410 void RenderWidgetHostViewAndroid::LockSurfaceForCopy() { |
411 DCHECK(HasValidFrame()); | 411 DCHECK(HasValidFrame()); |
412 DCHECK(host_); | 412 DCHECK(host_); |
413 DCHECK(!host_->is_hidden()); | 413 DCHECK(!host_->is_hidden()); |
414 frame_evictor_->LockFrame(); | 414 frame_evictor_->LockFrame(); |
415 } | 415 } |
416 | 416 |
417 void RenderWidgetHostViewAndroid::UnlockResources() { | 417 void RenderWidgetHostViewAndroid::UnlockSurfaceForCopy() { |
418 DCHECK(HasValidFrame()); | 418 DCHECK(HasValidFrame()); |
419 frame_evictor_->UnlockFrame(); | 419 frame_evictor_->UnlockFrame(); |
420 } | 420 } |
421 | 421 |
422 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { | 422 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { |
423 if (!content_view_core_) | 423 if (!content_view_core_) |
424 return gfx::Rect(default_size_); | 424 return gfx::Rect(default_size_); |
425 | 425 |
426 gfx::Size size = content_view_core_->GetViewportSizeDip(); | 426 gfx::Size size = content_view_core_->GetViewportSizeDip(); |
427 gfx::Size offset = content_view_core_->GetViewportSizeOffsetDip(); | 427 gfx::Size offset = content_view_core_->GetViewportSizeOffsetDip(); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 new cc::LatencyInfoSwapPromise(frame->metadata.latency_info[i])); | 842 new cc::LatencyInfoSwapPromise(frame->metadata.latency_info[i])); |
843 layer_->layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); | 843 layer_->layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); |
844 } | 844 } |
845 } | 845 } |
846 | 846 |
847 if (frame->delegated_frame_data) { | 847 if (frame->delegated_frame_data) { |
848 DCHECK(using_delegated_renderer_); | 848 DCHECK(using_delegated_renderer_); |
849 | 849 |
850 DCHECK(frame->delegated_frame_data); | 850 DCHECK(frame->delegated_frame_data); |
851 DCHECK(!frame->delegated_frame_data->render_pass_list.empty()); | 851 DCHECK(!frame->delegated_frame_data->render_pass_list.empty()); |
| 852 if (frame_evictor_->FrameLocked()) { |
| 853 base::Closure ack_callback = |
| 854 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, |
| 855 weak_ptr_factory_.GetWeakPtr(), |
| 856 output_surface_id); |
| 857 |
| 858 if (host_->is_hidden()) |
| 859 ack_callback.Run(); |
| 860 else |
| 861 ack_callbacks_.push(ack_callback); |
| 862 return; |
| 863 } |
852 | 864 |
853 cc::RenderPass* root_pass = | 865 cc::RenderPass* root_pass = |
854 frame->delegated_frame_data->render_pass_list.back(); | 866 frame->delegated_frame_data->render_pass_list.back(); |
855 texture_size_in_layer_ = root_pass->output_rect.size(); | 867 texture_size_in_layer_ = root_pass->output_rect.size(); |
856 ComputeContentsSize(frame->metadata); | 868 ComputeContentsSize(frame->metadata); |
857 | 869 |
858 SwapDelegatedFrame(output_surface_id, frame->delegated_frame_data.Pass()); | 870 SwapDelegatedFrame(output_surface_id, frame->delegated_frame_data.Pass()); |
859 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 871 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
860 return; | 872 return; |
861 } | 873 } |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 RunAckCallbacks(); | 1386 RunAckCallbacks(); |
1375 } | 1387 } |
1376 | 1388 |
1377 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1389 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
1378 DCHECK(content_view_core_); | 1390 DCHECK(content_view_core_); |
1379 DCHECK(!using_synchronous_compositor_); | 1391 DCHECK(!using_synchronous_compositor_); |
1380 RunAckCallbacks(); | 1392 RunAckCallbacks(); |
1381 } | 1393 } |
1382 | 1394 |
1383 void RenderWidgetHostViewAndroid::OnLostResources() { | 1395 void RenderWidgetHostViewAndroid::OnLostResources() { |
| 1396 while (frame_evictor_->FrameLocked()) { |
| 1397 UnlockSurfaceForCopy(); |
| 1398 } |
1384 if (texture_layer_.get()) | 1399 if (texture_layer_.get()) |
1385 texture_layer_->SetIsDrawable(false); | 1400 texture_layer_->SetIsDrawable(false); |
1386 if (delegated_renderer_layer_.get()) | 1401 if (delegated_renderer_layer_.get()) |
1387 DestroyDelegatedContent(); | 1402 DestroyDelegatedContent(); |
1388 texture_id_in_layer_ = 0; | 1403 texture_id_in_layer_ = 0; |
1389 RunAckCallbacks(); | 1404 RunAckCallbacks(); |
1390 } | 1405 } |
1391 | 1406 |
1392 // static | 1407 // static |
1393 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1408 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 // RenderWidgetHostView, public: | 1513 // RenderWidgetHostView, public: |
1499 | 1514 |
1500 // static | 1515 // static |
1501 RenderWidgetHostView* | 1516 RenderWidgetHostView* |
1502 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1517 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
1503 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1518 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
1504 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1519 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
1505 } | 1520 } |
1506 | 1521 |
1507 } // namespace content | 1522 } // namespace content |
OLD | NEW |