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

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

Issue 2688113002: Make ViewRoot the top of the ViewAndroid tree (Closed)
Patch Set: - Created 3 years, 10 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
Index: content/browser/renderer_host/compositor_impl_android.cc
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 49abcb2ce93af4880932990c093b24aec42ed6a5..bc346094b1aea747fec3548ae547b58d5463136e 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -65,6 +65,7 @@
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkMallocPixelRef.h"
+#include "ui/android/view_root.h"
#include "ui/android/window_android.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
@@ -84,7 +85,7 @@ gpu::SharedMemoryLimits GetCompositorContextSharedMemoryLimits(
gfx::NativeWindow window) {
constexpr size_t kBytesPerPixel = 4;
const gfx::Size size = display::Screen::GetScreen()
- ->GetDisplayNearestWindow(window)
+ ->GetDisplayNearestWindowAndroid(window)
.GetSizeInPixel();
const size_t full_screen_texture_size_in_bytes =
size.width() * size.height() * kBytesPerPixel;
@@ -309,8 +310,8 @@ base::LazyInstance<SingleThreadTaskGraphRunner> g_task_graph_runner =
// static
Compositor* Compositor::Create(CompositorClient* client,
- gfx::NativeWindow root_window) {
- return client ? new CompositorImpl(client, root_window) : NULL;
+ ui::ViewRoot* view_root) {
+ return client ? new CompositorImpl(client, view_root) : NULL;
}
// static
@@ -325,14 +326,15 @@ bool CompositorImpl::IsInitialized() {
}
CompositorImpl::CompositorImpl(CompositorClient* client,
- gfx::NativeWindow root_window)
+ ui::ViewRoot* view_root)
: frame_sink_id_(
ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()),
- resource_manager_(root_window),
+ resource_manager_(view_root->GetWindowAndroid()),
window_(NULL),
surface_handle_(gpu::kNullSurfaceHandle),
client_(client),
- root_window_(root_window),
+ root_window_(view_root->GetWindowAndroid()),
+ view_root_(view_root),
needs_animate_(false),
pending_swapbuffers_(0U),
num_successive_context_creation_failures_(0),
@@ -342,20 +344,20 @@ CompositorImpl::CompositorImpl(CompositorClient* client,
->GetSurfaceManager()
->RegisterFrameSinkId(frame_sink_id_);
DCHECK(client);
- DCHECK(root_window);
- DCHECK(root_window->GetLayer() == nullptr);
- root_window->SetLayer(cc::Layer::Create());
+ DCHECK(view_root);
+ DCHECK(view_root->GetLayer() == nullptr);
+ view_root->SetLayer(cc::Layer::Create());
readback_layer_tree_ = cc::Layer::Create();
readback_layer_tree_->SetHideLayerAndSubtree(true);
- root_window->GetLayer()->AddChild(readback_layer_tree_);
- root_window->AttachCompositor(this);
+ view_root->GetLayer()->AddChild(readback_layer_tree_);
+ root_window_->AttachCompositor(this);
CreateLayerTreeHost();
resource_manager_.Init(host_->GetUIResourceManager());
}
CompositorImpl::~CompositorImpl() {
root_window_->DetachCompositor();
- root_window_->SetLayer(nullptr);
+ view_root_->SetLayer(nullptr);
// Clean-up any surface references.
SetSurface(NULL);
ui::ContextProviderFactory::GetInstance()
@@ -376,9 +378,9 @@ void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) {
subroot_layer_->RemoveFromParent();
subroot_layer_ = NULL;
}
- if (root_window_->GetLayer()) {
- subroot_layer_ = root_window_->GetLayer();
- root_window_->GetLayer()->AddChild(root_layer);
+ if (view_root_->GetLayer()) {
+ subroot_layer_ = view_root_->GetLayer();
+ view_root_->GetLayer()->AddChild(root_layer);
}
}
@@ -443,7 +445,7 @@ void CompositorImpl::CreateLayerTreeHost() {
params.mutator_host = animation_host_.get();
host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
DCHECK(!host_->IsVisible());
- host_->SetRootLayer(root_window_->GetLayer());
+ host_->SetRootLayer(view_root_->GetLayer());
host_->SetFrameSinkId(frame_sink_id_);
host_->SetViewportSize(size_);
SetHasTransparentBackground(false);
@@ -485,7 +487,7 @@ void CompositorImpl::SetWindowBounds(const gfx::Size& size) {
host_->SetViewportSize(size);
if (display_)
display_->Resize(size);
- root_window_->GetLayer()->SetBounds(size);
+ view_root_->GetLayer()->SetBounds(size);
}
void CompositorImpl::SetHasTransparentBackground(bool transparent) {
@@ -726,7 +728,7 @@ void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
void CompositorImpl::RequestCopyOfOutputOnRootLayer(
std::unique_ptr<cc::CopyOutputRequest> request) {
- root_window_->GetLayer()->RequestCopyOfOutput(std::move(request));
+ view_root_->GetLayer()->RequestCopyOfOutput(std::move(request));
}
void CompositorImpl::SetNeedsAnimate() {

Powered by Google App Engine
This is Rietveld 408576698