Commit a2c23355 authored by Chris Blume's avatar Chris Blume Committed by Commit Bot

WindowPortLocal to use alloctor's copy

The LSI allocators previously did not store a copy of the last generated
LSI. As a result, many call sites would have to keep their own copies.

Now that the LSI allocators have their own copies, the call sites can be
updated to no longer store a separate copy.

WindowPortLocal is one such call site.

BUG=759031

Change-Id: I174529bdc83d97fe84f5c6e9ee595b2dd67a4668
Reviewed-on: https://chromium-review.googlesource.com/1034454
Commit-Queue: Chris Blume <cblume@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554824}
parent fa9c81b1
......@@ -70,11 +70,11 @@ void WindowPortLocal::OnDeviceScaleFactorChanged(
float new_device_scale_factor) {
if (!window_->IsRootWindow() &&
last_device_scale_factor_ != new_device_scale_factor &&
local_surface_id_.is_valid()) {
GetCurrentLocalSurfaceId().is_valid()) {
last_device_scale_factor_ = new_device_scale_factor;
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
parent_local_surface_id_allocator_.GenerateId();
if (frame_sink_)
frame_sink_->SetLocalSurfaceId(local_surface_id_);
frame_sink_->SetLocalSurfaceId(GetCurrentLocalSurfaceId());
}
ScopedCursorHider hider(window_);
......@@ -96,11 +96,11 @@ void WindowPortLocal::OnVisibilityChanged(bool visible) {}
void WindowPortLocal::OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
if (!window_->IsRootWindow() && last_size_ != new_bounds.size() &&
local_surface_id_.is_valid()) {
GetCurrentLocalSurfaceId().is_valid()) {
last_size_ = new_bounds.size();
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
parent_local_surface_id_allocator_.GenerateId();
if (frame_sink_)
frame_sink_->SetLocalSurfaceId(local_surface_id_);
frame_sink_->SetLocalSurfaceId(GetCurrentLocalSurfaceId());
}
}
......@@ -135,7 +135,8 @@ WindowPortLocal::CreateLayerTreeFrameSink() {
}
void WindowPortLocal::AllocateLocalSurfaceId() {
SetLocalSurfaceId(parent_local_surface_id_allocator_.GenerateId());
parent_local_surface_id_allocator_.GenerateId();
UpdateLocalSurfaceId();
}
bool WindowPortLocal::IsLocalSurfaceIdAllocationSuppressed() const {
......@@ -150,21 +151,22 @@ viz::ScopedSurfaceIdAllocator WindowPortLocal::GetSurfaceIdAllocator(
void WindowPortLocal::UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceId& embedded_client_local_surface_id) {
SetLocalSurfaceId(parent_local_surface_id_allocator_.UpdateFromChild(
embedded_client_local_surface_id));
parent_local_surface_id_allocator_.UpdateFromChild(
embedded_client_local_surface_id);
UpdateLocalSurfaceId();
}
const viz::LocalSurfaceId& WindowPortLocal::GetLocalSurfaceId() {
if (!local_surface_id_.is_valid())
if (!GetCurrentLocalSurfaceId().is_valid())
AllocateLocalSurfaceId();
return local_surface_id_;
return GetCurrentLocalSurfaceId();
}
void WindowPortLocal::OnEventTargetingPolicyChanged() {}
void WindowPortLocal::OnSurfaceChanged(const viz::SurfaceInfo& surface_info) {
DCHECK_EQ(surface_info.id().frame_sink_id(), window_->GetFrameSinkId());
DCHECK_EQ(surface_info.id().local_surface_id(), local_surface_id_);
DCHECK_EQ(surface_info.id().local_surface_id(), GetCurrentLocalSurfaceId());
window_->layer()->SetShowPrimarySurface(
surface_info.id(), window_->bounds().size(), SK_ColorWHITE,
cc::DeadlinePolicy::UseDefaultDeadline(),
......@@ -176,13 +178,15 @@ bool WindowPortLocal::ShouldRestackTransientChildren() {
return true;
}
void WindowPortLocal::SetLocalSurfaceId(
const viz::LocalSurfaceId& local_surface_id) {
void WindowPortLocal::UpdateLocalSurfaceId() {
last_device_scale_factor_ = ui::GetScaleFactorForNativeView(window_);
last_size_ = window_->bounds().size();
local_surface_id_ = local_surface_id;
if (frame_sink_)
frame_sink_->SetLocalSurfaceId(local_surface_id_);
frame_sink_->SetLocalSurfaceId(GetCurrentLocalSurfaceId());
}
const viz::LocalSurfaceId& WindowPortLocal::GetCurrentLocalSurfaceId() const {
return parent_local_surface_id_allocator_.GetCurrentLocalSurfaceId();
}
} // namespace aura
......@@ -58,12 +58,12 @@ class AURA_EXPORT WindowPortLocal : public WindowPort {
private:
void OnSurfaceChanged(const viz::SurfaceInfo& surface_info);
void SetLocalSurfaceId(const viz::LocalSurfaceId& local_surface_id);
void UpdateLocalSurfaceId();
const viz::LocalSurfaceId& GetCurrentLocalSurfaceId() const;
Window* const window_;
gfx::Size last_size_;
float last_device_scale_factor_ = 1.0f;
viz::LocalSurfaceId local_surface_id_;
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
base::WeakPtr<cc::LayerTreeFrameSink> frame_sink_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment