Chromium Code Reviews| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 return; | 497 return; |
| 498 | 498 |
| 499 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); | 499 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { | 502 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { |
| 503 } | 503 } |
| 504 | 504 |
| 505 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( | 505 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( |
| 506 scoped_ptr<cc::CompositorFrame> frame) { | 506 scoped_ptr<cc::CompositorFrame> frame) { |
| 507 // Always let ContentViewCore know about the new frame first, so it can decide | |
|
Sami
2013/04/16 09:44:21
Should this be after the early-out below?
no sievers
2013/04/16 16:06:32
ContentViewCoreImpl has these UpdateFrameInfo call
Sami
2013/04/16 16:19:21
Ah, gotcha. We still need to support the SurfaceTe
| |
| 508 // to schedule a Draw immediately when it sees the texture layer invalidation. | |
| 509 if (content_view_core_) { | |
| 510 // All offsets and sizes are in CSS pixels. | |
| 511 content_view_core_->UpdateFrameInfo( | |
| 512 frame->metadata.root_scroll_offset, | |
| 513 frame->metadata.page_scale_factor, | |
| 514 gfx::Vector2dF(frame->metadata.min_page_scale_factor, | |
| 515 frame->metadata.max_page_scale_factor), | |
| 516 frame->metadata.root_layer_size, | |
| 517 frame->metadata.viewport_size, | |
| 518 frame->metadata.location_bar_offset, | |
| 519 frame->metadata.location_bar_content_translation, | |
| 520 frame->metadata.overdraw_bottom_height); | |
| 521 } | |
| 522 | |
| 507 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) | 523 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) |
| 508 return; | 524 return; |
| 509 | 525 |
| 510 base::Closure callback = base::Bind(&InsertSyncPointAndAckForCompositor, | 526 base::Closure callback = base::Bind(&InsertSyncPointAndAckForCompositor, |
| 511 host_->GetProcess()->GetID(), | 527 host_->GetProcess()->GetID(), |
| 512 host_->GetRoutingID(), | 528 host_->GetRoutingID(), |
| 513 current_mailbox_, | 529 current_mailbox_, |
| 514 texture_size_in_layer_); | 530 texture_size_in_layer_); |
| 515 ImageTransportFactoryAndroid::GetInstance()->WaitSyncPoint( | 531 ImageTransportFactoryAndroid::GetInstance()->WaitSyncPoint( |
| 516 frame->gl_frame_data->sync_point); | 532 frame->gl_frame_data->sync_point); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 ImageTransportFactoryAndroid::GetInstance()->ReleaseTexture( | 594 ImageTransportFactoryAndroid::GetInstance()->ReleaseTexture( |
| 579 texture_id_in_layer_, current_mailbox_.name); | 595 texture_id_in_layer_, current_mailbox_.name); |
| 580 } else { | 596 } else { |
| 581 texture_id_in_layer_ = factory->CreateTexture(); | 597 texture_id_in_layer_ = factory->CreateTexture(); |
| 582 texture_layer_->SetTextureId(texture_id_in_layer_); | 598 texture_layer_->SetTextureId(texture_id_in_layer_); |
| 583 } | 599 } |
| 584 | 600 |
| 585 ImageTransportFactoryAndroid::GetInstance()->AcquireTexture( | 601 ImageTransportFactoryAndroid::GetInstance()->AcquireTexture( |
| 586 texture_id_in_layer_, mailbox.name); | 602 texture_id_in_layer_, mailbox.name); |
| 587 | 603 |
| 588 // We need to tell ContentViewCore about the new frame before calling | |
| 589 // setNeedsDisplay() below so that it has the needed information schedule the | |
| 590 // next compositor frame. | |
| 591 if (content_view_core_) | |
| 592 content_view_core_->DidProduceRendererFrame(); | |
| 593 | |
| 594 texture_layer_->SetNeedsDisplay(); | 604 texture_layer_->SetNeedsDisplay(); |
| 595 texture_layer_->SetBounds(gfx::Size(content_size.width(), | 605 texture_layer_->SetBounds(gfx::Size(content_size.width(), |
| 596 content_size.height())); | 606 content_size.height())); |
| 597 | 607 |
| 598 // Calculate the uv_max based on the content size relative to the texture | 608 // Calculate the uv_max based on the content size relative to the texture |
| 599 // size. | 609 // size. |
| 600 gfx::PointF uv_max; | 610 gfx::PointF uv_max; |
| 601 if (texture_size.GetArea() > 0) { | 611 if (texture_size.GetArea() > 0) { |
| 602 uv_max.SetPoint(content_size.width() / texture_size.width(), | 612 uv_max.SetPoint(content_size.width() / texture_size.width(), |
| 603 content_size.height() / texture_size.height()); | 613 content_size.height() / texture_size.height()); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 | 748 |
| 739 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { | 749 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { |
| 740 if (host_) | 750 if (host_) |
| 741 host_->MoveCaret(point); | 751 host_->MoveCaret(point); |
| 742 } | 752 } |
| 743 | 753 |
| 744 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 754 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 745 return cached_background_color_; | 755 return cached_background_color_; |
| 746 } | 756 } |
| 747 | 757 |
| 748 void RenderWidgetHostViewAndroid::UpdateFrameInfo( | |
| 749 const gfx::Vector2dF& scroll_offset, | |
| 750 float page_scale_factor, | |
| 751 const gfx::Vector2dF& page_scale_factor_limits, | |
| 752 const gfx::SizeF& content_size, | |
| 753 const gfx::SizeF& viewport_size, | |
| 754 const gfx::Vector2dF& controls_offset, | |
| 755 const gfx::Vector2dF& content_offset, | |
| 756 float overdraw_bottom_height) { | |
| 757 if (content_view_core_) { | |
| 758 // All offsets and sizes are in CSS pixels. | |
| 759 content_view_core_->UpdateFrameInfo( | |
| 760 scroll_offset, page_scale_factor, page_scale_factor_limits, | |
| 761 content_size, viewport_size, controls_offset, content_offset, | |
| 762 overdraw_bottom_height); | |
| 763 } | |
| 764 } | |
| 765 | |
| 766 void RenderWidgetHostViewAndroid::SetContentViewCore( | 758 void RenderWidgetHostViewAndroid::SetContentViewCore( |
| 767 ContentViewCoreImpl* content_view_core) { | 759 ContentViewCoreImpl* content_view_core) { |
| 768 if (content_view_core_ && is_layer_attached_) | 760 if (content_view_core_ && is_layer_attached_) |
| 769 content_view_core_->RemoveLayer(layer_); | 761 content_view_core_->RemoveLayer(layer_); |
| 770 | 762 |
| 771 content_view_core_ = content_view_core; | 763 content_view_core_ = content_view_core; |
| 772 if (content_view_core_ && is_layer_attached_) | 764 if (content_view_core_ && is_layer_attached_) |
| 773 content_view_core_->AttachLayer(layer_); | 765 content_view_core_->AttachLayer(layer_); |
| 774 } | 766 } |
| 775 | 767 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 798 // RenderWidgetHostView, public: | 790 // RenderWidgetHostView, public: |
| 799 | 791 |
| 800 // static | 792 // static |
| 801 RenderWidgetHostView* | 793 RenderWidgetHostView* |
| 802 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 794 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 803 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 795 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 804 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 796 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 805 } | 797 } |
| 806 | 798 |
| 807 } // namespace content | 799 } // namespace content |
| OLD | NEW |