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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 WasHidden(); | 398 WasHidden(); |
399 } | 399 } |
400 | 400 |
401 bool RenderWidgetHostViewAndroid::IsShowing() { | 401 bool RenderWidgetHostViewAndroid::IsShowing() { |
402 // ContentViewCoreImpl represents the native side of the Java | 402 // ContentViewCoreImpl represents the native side of the Java |
403 // ContentViewCore. It being NULL means that it is not attached | 403 // ContentViewCore. It being NULL means that it is not attached |
404 // to the View system yet, so we treat this RWHVA as hidden. | 404 // to the View system yet, so we treat this RWHVA as hidden. |
405 return is_showing_ && content_view_core_; | 405 return is_showing_ && content_view_core_; |
406 } | 406 } |
407 | 407 |
408 void RenderWidgetHostViewAndroid::LockResources() { | 408 void RenderWidgetHostViewAndroid::LockSurfaceForCopy() { |
409 DCHECK(HasValidFrame()); | 409 DCHECK(HasValidFrame()); |
410 DCHECK(host_); | 410 DCHECK(host_); |
411 DCHECK(!host_->is_hidden()); | 411 DCHECK(!host_->is_hidden()); |
412 frame_evictor_->LockFrame(); | 412 frame_evictor_->LockFrame(); |
413 } | 413 } |
414 | 414 |
415 void RenderWidgetHostViewAndroid::UnlockResources() { | 415 void RenderWidgetHostViewAndroid::UnlockSurfaceForCopy() { |
416 DCHECK(HasValidFrame()); | 416 DCHECK(HasValidFrame()); |
417 frame_evictor_->UnlockFrame(); | 417 frame_evictor_->UnlockFrame(); |
418 } | 418 } |
419 | 419 |
420 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { | 420 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { |
421 if (!content_view_core_) | 421 if (!content_view_core_) |
422 return gfx::Rect(default_size_); | 422 return gfx::Rect(default_size_); |
423 | 423 |
424 gfx::Size size = content_view_core_->GetViewportSizeDip(); | 424 gfx::Size size = content_view_core_->GetViewportSizeDip(); |
425 gfx::Size offset = content_view_core_->GetViewportSizeOffsetDip(); | 425 gfx::Size offset = content_view_core_->GetViewportSizeOffsetDip(); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 new cc::LatencyInfoSwapPromise(frame->metadata.latency_info[i])); | 830 new cc::LatencyInfoSwapPromise(frame->metadata.latency_info[i])); |
831 layer_->layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); | 831 layer_->layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); |
832 } | 832 } |
833 } | 833 } |
834 | 834 |
835 if (frame->delegated_frame_data) { | 835 if (frame->delegated_frame_data) { |
836 DCHECK(using_delegated_renderer_); | 836 DCHECK(using_delegated_renderer_); |
837 | 837 |
838 DCHECK(frame->delegated_frame_data); | 838 DCHECK(frame->delegated_frame_data); |
839 DCHECK(!frame->delegated_frame_data->render_pass_list.empty()); | 839 DCHECK(!frame->delegated_frame_data->render_pass_list.empty()); |
| 840 if (frame_evictor_->FrameLocked()) { |
| 841 base::Closure ack_callback = |
| 842 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, |
| 843 weak_ptr_factory_.GetWeakPtr(), |
| 844 output_surface_id); |
| 845 |
| 846 if (host_->is_hidden()) |
| 847 ack_callback.Run(); |
| 848 else |
| 849 ack_callbacks_.push(ack_callback); |
| 850 return; |
| 851 } |
840 | 852 |
841 cc::RenderPass* root_pass = | 853 cc::RenderPass* root_pass = |
842 frame->delegated_frame_data->render_pass_list.back(); | 854 frame->delegated_frame_data->render_pass_list.back(); |
843 texture_size_in_layer_ = root_pass->output_rect.size(); | 855 texture_size_in_layer_ = root_pass->output_rect.size(); |
844 ComputeContentsSize(frame->metadata); | 856 ComputeContentsSize(frame->metadata); |
845 | 857 |
846 SwapDelegatedFrame(output_surface_id, frame->delegated_frame_data.Pass()); | 858 SwapDelegatedFrame(output_surface_id, frame->delegated_frame_data.Pass()); |
847 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 859 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
848 return; | 860 return; |
849 } | 861 } |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 RunAckCallbacks(); | 1328 RunAckCallbacks(); |
1317 } | 1329 } |
1318 | 1330 |
1319 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1331 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
1320 DCHECK(content_view_core_); | 1332 DCHECK(content_view_core_); |
1321 DCHECK(!using_synchronous_compositor_); | 1333 DCHECK(!using_synchronous_compositor_); |
1322 RunAckCallbacks(); | 1334 RunAckCallbacks(); |
1323 } | 1335 } |
1324 | 1336 |
1325 void RenderWidgetHostViewAndroid::OnLostResources() { | 1337 void RenderWidgetHostViewAndroid::OnLostResources() { |
| 1338 while (frame_evictor_->FrameLocked()) { |
| 1339 UnlockSurfaceForCopy(); |
| 1340 } |
1326 if (texture_layer_.get()) | 1341 if (texture_layer_.get()) |
1327 texture_layer_->SetIsDrawable(false); | 1342 texture_layer_->SetIsDrawable(false); |
1328 if (delegated_renderer_layer_.get()) | 1343 if (delegated_renderer_layer_.get()) |
1329 DestroyDelegatedContent(); | 1344 DestroyDelegatedContent(); |
1330 texture_id_in_layer_ = 0; | 1345 texture_id_in_layer_ = 0; |
1331 RunAckCallbacks(); | 1346 RunAckCallbacks(); |
1332 } | 1347 } |
1333 | 1348 |
1334 // static | 1349 // static |
1335 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1350 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 // RenderWidgetHostView, public: | 1455 // RenderWidgetHostView, public: |
1441 | 1456 |
1442 // static | 1457 // static |
1443 RenderWidgetHostView* | 1458 RenderWidgetHostView* |
1444 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1459 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
1445 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1460 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
1446 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1461 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
1447 } | 1462 } |
1448 | 1463 |
1449 } // namespace content | 1464 } // namespace content |
OLD | NEW |