Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1317)

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2133873004: content: Move Surfaces related code out of RWHVA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index efe0d820a15ad79b7389aafb41649ac4f1cdd445..0b420a11185a908f0956bbeb7f6b05151b8d4672 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -30,10 +30,8 @@
#include "cc/output/copy_output_result.h"
#include "cc/output/latency_info_swap_promise.h"
#include "cc/resources/single_release_callback.h"
-#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_factory.h"
#include "cc/surfaces/surface_id_allocator.h"
-#include "cc/surfaces/surface_manager.h"
#include "cc/trees/layer_tree_host.h"
#include "components/display_compositor/gl_helper.h"
#include "content/browser/accessibility/browser_accessibility_manager_android.h"
@@ -95,24 +93,6 @@ namespace content {
namespace {
-void SatisfyCallback(cc::SurfaceManager* manager,
- const cc::SurfaceSequence& sequence) {
- std::vector<uint32_t> sequences;
- sequences.push_back(sequence.sequence);
- manager->DidSatisfySequences(sequence.id_namespace, &sequences);
-}
-
-void RequireCallback(cc::SurfaceManager* manager,
- const cc::SurfaceId& id,
- const cc::SurfaceSequence& sequence) {
- cc::Surface* surface = manager->GetSurfaceForId(id);
- if (!surface) {
- LOG(ERROR) << "Attempting to require callback on nonexistent surface";
- return;
- }
- surface->AddDestructionDependency(sequence);
-}
-
const int kUndefinedOutputSurfaceId = -1;
static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
@@ -284,24 +264,6 @@ gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) {
return rect;
}
-scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer(
- const cc::SurfaceId& surface_id,
- const gfx::Size& size) {
- DCHECK(!surface_id.is_null());
- cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager();
- DCHECK(manager);
- // manager must outlive compositors using it.
- scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create(
- base::Bind(&SatisfyCallback, base::Unretained(manager)),
- base::Bind(&RequireCallback, base::Unretained(manager)));
- surface_layer->SetSurfaceId(surface_id, 1.f, size);
- surface_layer->SetBounds(size);
- surface_layer->SetIsDrawable(true);
- surface_layer->SetContentsOpaque(true);
-
- return surface_layer;
-}
-
} // anonymous namespace
RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo(
@@ -343,8 +305,6 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
locks_on_frame_count_(0),
observing_root_window_(false),
weak_ptr_factory_(this) {
- if (CompositorImpl::GetSurfaceManager())
- id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator();
host_->SetView(this);
SetContentViewCore(content_view_core);
}
@@ -354,8 +314,7 @@ RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
content_view_core_->RemoveObserver(this);
SetContentViewCore(NULL);
DCHECK(ack_callbacks_.empty());
- DCHECK(!surface_factory_);
- DCHECK(surface_id_.is_null());
+ DCHECK(!delegated_frame_host_);
}
void RenderWidgetHostViewAndroid::Blur() {
@@ -804,12 +763,7 @@ void RenderWidgetHostViewAndroid::Destroy() {
RemoveLayers();
SetContentViewCore(NULL);
- if (!surface_id_.is_null()) {
- DCHECK(surface_factory_.get());
- surface_factory_->Destroy(surface_id_);
- surface_id_ = cc::SurfaceId();
- }
- surface_factory_.reset();
+ delegated_frame_host_.reset();
// The RenderWidgetHost's destruction led here, so don't call it.
host_ = NULL;
@@ -895,7 +849,7 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
ui::WindowAndroidCompositor* compositor =
content_view_core_->GetWindowAndroid()->GetCompositor();
DCHECK(compositor);
- DCHECK(!surface_id_.is_null());
+ DCHECK(delegated_frame_host_->HasDelegatedContent());
std::unique_ptr<cc::CopyOutputRequest> request =
cc::CopyOutputRequest::CreateRequest(base::Bind(
&PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(),
@@ -955,7 +909,7 @@ void RenderWidgetHostViewAndroid::SendReturnedDelegatedResources(
output_surface_id, ack));
}
-void RenderWidgetHostViewAndroid::ReturnResources(
+void RenderWidgetHostViewAndroid::ReturnCompositorFrameResources(
const cc::ReturnedResourceArray& resources) {
if (resources.empty())
return;
@@ -965,65 +919,27 @@ void RenderWidgetHostViewAndroid::ReturnResources(
SendReturnedDelegatedResources(last_output_surface_id_);
}
-void RenderWidgetHostViewAndroid::SetBeginFrameSource(
- cc::BeginFrameSource* begin_frame_source) {
- // TODO(tansell): Hook this up.
-}
-
void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
- RemoveLayers();
- if (!surface_id_.is_null()) {
- DCHECK(surface_factory_.get());
- surface_factory_->Destroy(surface_id_);
- surface_id_ = cc::SurfaceId();
- }
- layer_ = NULL;
+ if (!delegated_frame_host_)
+ return;
+
+ delegated_frame_host_->DestroyDelegatedContent();
}
void RenderWidgetHostViewAndroid::CheckOutputSurfaceChanged(
uint32_t output_surface_id) {
if (output_surface_id == last_output_surface_id_)
return;
- DestroyDelegatedContent();
- surface_factory_.reset();
+
+ delegated_frame_host_.reset();
if (!surface_returned_resources_.empty())
SendReturnedDelegatedResources(last_output_surface_id_);
- last_output_surface_id_ = output_surface_id;
-}
-
-void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
- cc::CompositorFrame frame) {
- cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager();
- if (!surface_factory_) {
- surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this));
- }
- if (surface_id_.is_null() ||
- texture_size_in_layer_ != current_surface_size_ ||
- location_bar_content_translation_ !=
- frame.metadata.location_bar_content_translation ||
- current_viewport_selection_ != frame.metadata.selection) {
- RemoveLayers();
- if (!surface_id_.is_null())
- surface_factory_->Destroy(surface_id_);
- surface_id_ = id_allocator_->GenerateId();
- surface_factory_->Create(surface_id_);
- layer_ = CreateSurfaceLayer(surface_id_, texture_size_in_layer_);
-
- DCHECK(layer_);
-
- current_surface_size_ = texture_size_in_layer_;
- location_bar_content_translation_ =
- frame.metadata.location_bar_content_translation;
- current_viewport_selection_ = frame.metadata.selection;
- AttachLayers();
- }
+ delegated_frame_host_.reset(new DelegatedFrameHostAndroid(
+ CompositorImpl::GetSurfaceManager(),
+ CompositorImpl::CreateSurfaceIdAllocator(), this));
- cc::SurfaceFactory::DrawCallback ack_callback =
- base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks,
- weak_ptr_factory_.GetWeakPtr());
- surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
- ack_callback);
+ last_output_surface_id_ = output_surface_id;
}
void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
@@ -1048,6 +964,8 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
CheckOutputSurfaceChanged(output_surface_id);
+ DCHECK(delegated_frame_host_);
+
bool has_content = !texture_size_in_layer_.IsEmpty();
base::Closure ack_callback =
@@ -1060,7 +978,12 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
if (!has_content) {
DestroyDelegatedContent();
} else {
- SubmitCompositorFrame(std::move(frame));
+ delegated_frame_host_->SubmitCompositorFrame(
+ std::move(frame),
+ base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks,
+ weak_ptr_factory_.GetWeakPtr()));
+ DCHECK(layer_);
+
layer_->SetIsDrawable(true);
layer_->SetContentsOpaque(true);
layer_->SetBounds(texture_size_in_layer_);
@@ -1194,6 +1117,17 @@ RenderWidgetHostViewAndroid::CreateDrawable() {
content_view_core_->GetContext().obj()));
}
+void RenderWidgetHostViewAndroid::AttachSurfaceLayer(
Khushal 2016/07/12 02:02:25 I was looking at removing the Attach and Detach Su
+ scoped_refptr<cc::SurfaceLayer> layer) {
+ layer_ = std::move(layer);
+ AttachLayers();
+}
+
+void RenderWidgetHostViewAndroid::DetachSurfaceLayer() {
+ RemoveLayers();
+ layer_ = nullptr;
+}
+
void RenderWidgetHostViewAndroid::SynchronousCopyContents(
const gfx::Rect& src_subrect_in_pixel,
const gfx::Size& dst_size_in_pixel,
@@ -1455,8 +1389,7 @@ void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() {
void RenderWidgetHostViewAndroid::EvictDelegatedFrame() {
DCHECK_EQ(locks_on_frame_count_, 0u);
frame_evictor_->DiscardedFrame();
- if (layer_.get())
- DestroyDelegatedContent();
+ DestroyDelegatedContent();
}
bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
@@ -1679,9 +1612,10 @@ void RenderWidgetHostViewAndroid::DidStopFlinging() {
}
uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() {
- if (id_allocator_)
- return id_allocator_->id_namespace();
- return 0;
+ if (!delegated_frame_host_)
+ return 0;
+
+ return delegated_frame_host_->GetSurfaceIdNamespace();
}
void RenderWidgetHostViewAndroid::SetContentViewCore(
@@ -1859,8 +1793,7 @@ void RenderWidgetHostViewAndroid::OnActivityStarted() {
void RenderWidgetHostViewAndroid::OnLostResources() {
ReleaseLocksOnSurface();
- if (layer_.get())
- DestroyDelegatedContent();
+ DestroyDelegatedContent();
DCHECK(ack_callbacks_.empty());
}
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698