aura: Sanitize LocalSurfaceId allocation for WindowTreeHost.
Notable changes: . Use the regular aura-path for setting the LocalSurfaceId for the compositor, instead of specially setting it from WindowTreeClient, when the window-server sets the LocalSurfaceId with a bounds-change. WindowTreeHost::SetBoundsInPixels() is changed to take LocalSurfaceId as an input-param to facilitate this. . When the client itself changes the size, do not set the LocalSurfaceId on the compositor multiple times for the same size from various places (e.g. WindowTreeHostMus, WindowTreeClient etc.). . Add validation checks for ui::Compositor that a new LocalSurfaceId is assigned whenever the size changes. This makes it easier to catch errors earlier in the pipeline. BUG=821987 Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel Change-Id: Ic9703c57b7a7f9ef2b65b34fa38c8ec7de9e9f36 Reviewed-on: https://chromium-review.googlesource.com/1014568 Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Cr-Commit-Position: refs/heads/master@{#551588}
This commit is contained in:

committed by
Commit Bot

parent
64bf2e447a
commit
3c7fdca95b
ash/host
ash_window_tree_host_mus_unified.ccash_window_tree_host_mus_unified.hash_window_tree_host_platform.ccash_window_tree_host_platform.hash_window_tree_host_unified.ccash_window_tree_host_unified.h
components/viz/client
headless/lib/browser
ui
@ -85,8 +85,10 @@ void AshWindowTreeHostMusUnified::RegisterMirroringHost(
|
||||
mirroring_ash_host->AsWindowTreeHost()->window()->AddObserver(this);
|
||||
}
|
||||
|
||||
void AshWindowTreeHostMusUnified::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
AshWindowTreeHostMus::SetBoundsInPixels(bounds);
|
||||
void AshWindowTreeHostMusUnified::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
AshWindowTreeHostMus::SetBoundsInPixels(bounds, local_surface_id);
|
||||
OnHostResizedInPixels(bounds.size());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,8 @@ class AshWindowTreeHostMusUnified : public AshWindowTreeHostMus,
|
||||
void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) override;
|
||||
|
||||
// aura::WindowTreeHost:
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) override;
|
||||
void SetCursorNative(gfx::NativeCursor cursor) override;
|
||||
void OnCursorVisibilityChangedNative(bool show) override;
|
||||
|
||||
|
@ -134,8 +134,10 @@ void AshWindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) {
|
||||
SetTapToClickPaused(!show);
|
||||
}
|
||||
|
||||
void AshWindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
WindowTreeHostPlatform::SetBoundsInPixels(bounds);
|
||||
void AshWindowTreeHostPlatform::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
WindowTreeHostPlatform::SetBoundsInPixels(bounds, local_surface_id);
|
||||
ConfineCursorToRootWindow();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,8 @@ class ASH_EXPORT AshWindowTreeHostPlatform
|
||||
gfx::Rect GetTransformedRootWindowBoundsInPixels(
|
||||
const gfx::Size& host_size_in_pixels) const override;
|
||||
void OnCursorVisibilityChangedNative(bool show) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) override;
|
||||
void DispatchEvent(ui::Event* event) override;
|
||||
|
||||
private:
|
||||
|
@ -92,8 +92,10 @@ void AshWindowTreeHostUnified::RegisterMirroringHost(
|
||||
mirroring_ash_host->AsWindowTreeHost()->window()->AddObserver(this);
|
||||
}
|
||||
|
||||
void AshWindowTreeHostUnified::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
AshWindowTreeHostPlatform::SetBoundsInPixels(bounds);
|
||||
void AshWindowTreeHostUnified::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
AshWindowTreeHostPlatform::SetBoundsInPixels(bounds, local_surface_id);
|
||||
OnHostResizedInPixels(bounds.size());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,8 @@ class AshWindowTreeHostUnified : public AshWindowTreeHostPlatform,
|
||||
void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) override;
|
||||
|
||||
// aura::WindowTreeHost:
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) override;
|
||||
void SetCursorNative(gfx::NativeCursor cursor) override;
|
||||
void OnCursorVisibilityChangedNative(bool show) override;
|
||||
|
||||
|
@ -134,9 +134,12 @@ void ClientLayerTreeFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
|
||||
local_surface_id_ =
|
||||
local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame);
|
||||
} else {
|
||||
CHECK(local_surface_id_ != last_submitted_local_surface_id_ ||
|
||||
(last_submitted_device_scale_factor_ == frame.device_scale_factor() &&
|
||||
last_submitted_size_in_pixels_ == frame.size_in_pixels()));
|
||||
if (local_surface_id_ == last_submitted_local_surface_id_) {
|
||||
CHECK_EQ(last_submitted_device_scale_factor_,
|
||||
frame.device_scale_factor());
|
||||
CHECK_EQ(last_submitted_size_in_pixels_.ToString(),
|
||||
frame.size_in_pixels().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.ipc"),
|
||||
|
@ -53,7 +53,8 @@ void HeadlessBrowserImpl::PlatformInitializeWebContents(
|
||||
void HeadlessBrowserImpl::PlatformSetWebContentsBounds(
|
||||
HeadlessWebContentsImpl* web_contents,
|
||||
const gfx::Rect& bounds) {
|
||||
web_contents->window_tree_host()->SetBoundsInPixels(bounds);
|
||||
web_contents->window_tree_host()->SetBoundsInPixels(bounds,
|
||||
viz::LocalSurfaceId());
|
||||
web_contents->window_tree_host()->window()->SetBounds(bounds);
|
||||
|
||||
gfx::NativeView native_view = web_contents->web_contents()->GetNativeView();
|
||||
|
@ -54,14 +54,16 @@ gfx::Rect HeadlessWindowTreeHost::GetBoundsInPixels() const {
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
void HeadlessWindowTreeHost::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
void HeadlessWindowTreeHost::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
bool origin_changed = bounds_.origin() != bounds.origin();
|
||||
bool size_changed = bounds_.size() != bounds.size();
|
||||
bounds_ = bounds;
|
||||
if (origin_changed)
|
||||
OnHostMovedInPixels(bounds.origin());
|
||||
if (size_changed)
|
||||
OnHostResizedInPixels(bounds.size());
|
||||
OnHostResizedInPixels(bounds.size(), local_surface_id);
|
||||
}
|
||||
|
||||
void HeadlessWindowTreeHost::ShowImpl() {}
|
||||
|
@ -42,7 +42,8 @@ class HeadlessWindowTreeHost : public aura::WindowTreeHost,
|
||||
void ShowImpl() override;
|
||||
void HideImpl() override;
|
||||
gfx::Rect GetBoundsInPixels() const override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) override;
|
||||
gfx::Point GetLocationOnScreenInPixels() const override;
|
||||
void SetCapture() override;
|
||||
void ReleaseCapture() override;
|
||||
|
@ -304,6 +304,9 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
|
||||
viz::SurfaceInfo fallback_surface_info_;
|
||||
|
||||
viz::LocalSurfaceId local_surface_id_;
|
||||
// TODO(sad, fsamuel): For 'mash' mode, where the embedder is responsible for
|
||||
// allocating the LocalSurfaceIds, this should use a
|
||||
// ChildLocalSurfaceIdAllocator instead.
|
||||
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
|
||||
gfx::Size last_surface_size_in_pixels_;
|
||||
|
||||
|
@ -903,11 +903,9 @@ void WindowTreeClient::SetWindowBoundsFromServer(
|
||||
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
|
||||
if (IsRoot(window)) {
|
||||
// WindowTreeHost expects bounds to be in pixels.
|
||||
GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels);
|
||||
if (local_surface_id && local_surface_id->is_valid()) {
|
||||
ui::Compositor* compositor = window->GetWindow()->GetHost()->compositor();
|
||||
compositor->SetLocalSurfaceId(*local_surface_id);
|
||||
}
|
||||
GetWindowTreeHostMus(window)->SetBoundsFromServer(
|
||||
revert_bounds_in_pixels,
|
||||
local_surface_id ? *local_surface_id : viz::LocalSurfaceId());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1075,21 +1073,8 @@ void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
|
||||
// OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side
|
||||
// effect of those and can be ignored.
|
||||
if (IsRoot(window)) {
|
||||
// NOTE: this has to happen to here as during the call to
|
||||
// OnWindowTreeHostBoundsWillChange() the compositor hasn't been updated
|
||||
// yet.
|
||||
if (window->window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED) {
|
||||
WindowTreeHost* window_tree_host = window->GetWindow()->GetHost();
|
||||
// |window_tree_host| may be null if this is called during creation of
|
||||
// the window associated with the WindowTreeHostMus.
|
||||
if (window_tree_host) {
|
||||
viz::LocalSurfaceId local_surface_id =
|
||||
window->GetOrAllocateLocalSurfaceId(
|
||||
window_tree_host->GetBoundsInPixels().size());
|
||||
DCHECK(local_surface_id.is_valid());
|
||||
window_tree_host->compositor()->SetLocalSurfaceId(local_surface_id);
|
||||
}
|
||||
}
|
||||
// Do not set the LocalSurfaceId on the compositor here, because it has
|
||||
// already been set.
|
||||
return;
|
||||
}
|
||||
const float device_scale_factor = window->GetDeviceScaleFactor();
|
||||
|
@ -97,12 +97,6 @@ WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params)
|
||||
|
||||
// Mus windows are assumed hidden.
|
||||
compositor()->SetVisible(false);
|
||||
|
||||
if (window_mus->window_mus_type() ==
|
||||
WindowMusType::DISPLAY_MANUALLY_CREATED) {
|
||||
compositor()->SetLocalSurfaceId(
|
||||
window_mus->GetOrAllocateLocalSurfaceId(bounds_in_pixels.size()));
|
||||
}
|
||||
}
|
||||
|
||||
WindowTreeHostMus::~WindowTreeHostMus() {
|
||||
@ -126,9 +120,11 @@ WindowTreeHostMus* WindowTreeHostMus::ForWindow(aura::Window* window) {
|
||||
return root->GetProperty(kWindowTreeHostMusKey);
|
||||
}
|
||||
|
||||
void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds_in_pixels) {
|
||||
void WindowTreeHostMus::SetBoundsFromServer(
|
||||
const gfx::Rect& bounds_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true);
|
||||
SetBoundsInPixels(bounds_in_pixels);
|
||||
SetBoundsInPixels(bounds_in_pixels, local_surface_id);
|
||||
}
|
||||
|
||||
void WindowTreeHostMus::SetClientArea(
|
||||
@ -206,10 +202,12 @@ void WindowTreeHostMus::HideImpl() {
|
||||
window()->Hide();
|
||||
}
|
||||
|
||||
void WindowTreeHostMus::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
void WindowTreeHostMus::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
if (!in_set_bounds_from_server_)
|
||||
delegate_->OnWindowTreeHostBoundsWillChange(this, bounds);
|
||||
WindowTreeHostPlatform::SetBoundsInPixels(bounds);
|
||||
WindowTreeHostPlatform::SetBoundsInPixels(bounds, local_surface_id);
|
||||
}
|
||||
|
||||
void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
|
||||
|
@ -40,7 +40,8 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform {
|
||||
static WindowTreeHostMus* ForWindow(aura::Window* window);
|
||||
|
||||
// Sets the bounds in pixels.
|
||||
void SetBoundsFromServer(const gfx::Rect& bounds_in_pixels);
|
||||
void SetBoundsFromServer(const gfx::Rect& bounds_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id);
|
||||
|
||||
ui::EventDispatchDetails SendEventToSink(ui::Event* event) {
|
||||
return aura::WindowTreeHostPlatform::SendEventToSink(event);
|
||||
@ -97,7 +98,9 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform {
|
||||
|
||||
// aura::WindowTreeHostPlatform:
|
||||
void HideImpl() override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id =
|
||||
viz::LocalSurfaceId()) override;
|
||||
void DispatchEvent(ui::Event* event) override;
|
||||
void OnClosed() override;
|
||||
void OnActivationChanged(bool active) override;
|
||||
|
@ -49,6 +49,32 @@ bool ShouldAllocateLocalSurfaceId() {
|
||||
return Env::GetInstance()->mode() == Env::Mode::LOCAL;
|
||||
}
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
class ScopedLocalSurfaceIdValidator {
|
||||
public:
|
||||
explicit ScopedLocalSurfaceIdValidator(Window* window)
|
||||
: window_(window),
|
||||
local_surface_id_(window ? window->GetLocalSurfaceId()
|
||||
: viz::LocalSurfaceId()) {}
|
||||
~ScopedLocalSurfaceIdValidator() {
|
||||
if (ShouldAllocateLocalSurfaceId() && window_) {
|
||||
DCHECK_EQ(local_surface_id_, window_->GetLocalSurfaceId());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Window* const window_;
|
||||
const viz::LocalSurfaceId local_surface_id_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedLocalSurfaceIdValidator);
|
||||
};
|
||||
#else
|
||||
class ScopedLocalSurfaceIdValidator {
|
||||
public:
|
||||
explicit ScopedLocalSurfaceIdValidator(Window* window) {}
|
||||
~ScopedLocalSurfaceIdValidator() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -128,20 +154,13 @@ gfx::Transform WindowTreeHost::GetInverseRootTransformForLocalEventCoordinates()
|
||||
}
|
||||
|
||||
void WindowTreeHost::UpdateRootWindowSizeInPixels() {
|
||||
#if DCHECK_IS_ON()
|
||||
// Validate that the LocalSurfaceId does not change
|
||||
// Validate that the LocalSurfaceId does not change.
|
||||
bool compositor_inited = !!compositor()->root_layer();
|
||||
auto store_local_surface_id =
|
||||
compositor_inited ? window()->GetLocalSurfaceId() : viz::LocalSurfaceId();
|
||||
#endif
|
||||
ScopedLocalSurfaceIdValidator lsi_validator(compositor_inited ? window()
|
||||
: nullptr);
|
||||
gfx::Rect transformed_bounds_in_pixels =
|
||||
GetTransformedRootWindowBoundsInPixels(GetBoundsInPixels().size());
|
||||
window()->SetBounds(transformed_bounds_in_pixels);
|
||||
#if DCHECK_IS_ON()
|
||||
if (compositor_inited && ShouldAllocateLocalSurfaceId()) {
|
||||
DCHECK_EQ(store_local_surface_id, window()->GetLocalSurfaceId());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowTreeHost::ConvertDIPToScreenInPixels(gfx::Point* point) const {
|
||||
@ -354,19 +373,22 @@ void WindowTreeHost::OnHostMovedInPixels(
|
||||
}
|
||||
|
||||
void WindowTreeHost::OnHostResizedInPixels(
|
||||
const gfx::Size& new_size_in_pixels) {
|
||||
const gfx::Size& new_size_in_pixels,
|
||||
const viz::LocalSurfaceId& new_local_surface_id) {
|
||||
display::Display display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestWindow(window());
|
||||
device_scale_factor_ = display.device_scale_factor();
|
||||
|
||||
// Update the state of the root window.
|
||||
UpdateRootWindowSizeInPixels();
|
||||
|
||||
// Allocate a new LocalSurfaceId for the new state.
|
||||
if (ShouldAllocateLocalSurfaceId())
|
||||
auto local_surface_id = new_local_surface_id;
|
||||
if (ShouldAllocateLocalSurfaceId() && !new_local_surface_id.is_valid()) {
|
||||
window_->AllocateLocalSurfaceId();
|
||||
local_surface_id = window_->GetLocalSurfaceId();
|
||||
}
|
||||
ScopedLocalSurfaceIdValidator lsi_validator(window());
|
||||
compositor_->SetScaleAndSize(device_scale_factor_, new_size_in_pixels,
|
||||
window()->GetLocalSurfaceId());
|
||||
local_surface_id);
|
||||
|
||||
for (WindowTreeHostObserver& observer : observers_)
|
||||
observer.OnHostResized(this);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/optional.h"
|
||||
#include "components/viz/common/surfaces/frame_sink_id.h"
|
||||
#include "components/viz/common/surfaces/local_surface_id.h"
|
||||
#include "ui/aura/aura_export.h"
|
||||
#include "ui/base/cursor/cursor.h"
|
||||
#include "ui/base/ime/input_method_delegate.h"
|
||||
@ -180,14 +181,17 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
|
||||
// Hides the WindowTreeHost.
|
||||
void Hide();
|
||||
|
||||
// Gets/Sets the size of the WindowTreeHost (in pixels).
|
||||
// TODO(ccameron): The existence of OnHostMoved/ResizedInPixels and this
|
||||
// function create confusion as to the source of the true bounds. Should it
|
||||
// be expected that this will always return the values most recently
|
||||
// specified by OnHostMoved/ResizedInPixels? If so, why do we ask the
|
||||
// sub-classes to return the value when this class already knows the value?
|
||||
// Sets/Gets the bounds of the WindowTreeHost (in pixels). Note that a call to
|
||||
// GetBoundsInPixels() immediately following a SetBoundsInPixels() can return
|
||||
// the old bounds, because SetBoundsInPixels() can take effect asynchronously,
|
||||
// depending on the platform. The |local_surface_id| takes effect when (and
|
||||
// if) the new size is confirmed (potentially asynchronously) by the platform.
|
||||
// If |local_surface_id| is invalid, then a new LocalSurfaceId is allocated
|
||||
// when the size change takes effect.
|
||||
virtual void SetBoundsInPixels(
|
||||
const gfx::Rect& bounds_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id = viz::LocalSurfaceId()) = 0;
|
||||
virtual gfx::Rect GetBoundsInPixels() const = 0;
|
||||
virtual void SetBoundsInPixels(const gfx::Rect& bounds_in_pixels) = 0;
|
||||
|
||||
// Sets the OS capture to the root window.
|
||||
virtual void SetCapture() = 0;
|
||||
@ -230,10 +234,9 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
|
||||
virtual gfx::Point GetLocationOnScreenInPixels() const = 0;
|
||||
|
||||
void OnHostMovedInPixels(const gfx::Point& new_location_in_pixels);
|
||||
// TODO(ccameron): This needs to specify a device scale factor. It should
|
||||
// arguably be merged with OnHostMovedInPixels (since all callers are pulling
|
||||
// the size or position from a rect which also feeds OnHostMovedInPixels).
|
||||
void OnHostResizedInPixels(const gfx::Size& new_size_in_pixels);
|
||||
void OnHostResizedInPixels(
|
||||
const gfx::Size& new_size_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id = viz::LocalSurfaceId());
|
||||
void OnHostWorkspaceChanged();
|
||||
void OnHostDisplayChanged();
|
||||
void OnHostCloseRequested();
|
||||
|
@ -102,7 +102,11 @@ gfx::Rect WindowTreeHostPlatform::GetBoundsInPixels() const {
|
||||
return platform_window_ ? platform_window_->GetBounds() : gfx::Rect();
|
||||
}
|
||||
|
||||
void WindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
void WindowTreeHostPlatform::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
pending_size_ = bounds.size();
|
||||
pending_local_surface_id_ = local_surface_id;
|
||||
platform_window_->SetBounds(bounds);
|
||||
}
|
||||
|
||||
@ -162,8 +166,15 @@ void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) {
|
||||
bounds_ = new_bounds;
|
||||
if (bounds_.origin() != old_bounds.origin())
|
||||
OnHostMovedInPixels(bounds_.origin());
|
||||
if (bounds_.size() != old_bounds.size() || current_scale != new_scale)
|
||||
OnHostResizedInPixels(bounds_.size());
|
||||
if (pending_local_surface_id_.is_valid() ||
|
||||
bounds_.size() != old_bounds.size() || current_scale != new_scale) {
|
||||
auto local_surface_id = bounds_.size() == pending_size_
|
||||
? pending_local_surface_id_
|
||||
: viz::LocalSurfaceId();
|
||||
pending_local_surface_id_ = viz::LocalSurfaceId();
|
||||
pending_size_ = gfx::Size();
|
||||
OnHostResizedInPixels(bounds_.size(), local_surface_id);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowTreeHostPlatform::OnDamageRect(const gfx::Rect& damage_rect) {
|
||||
|
@ -33,7 +33,8 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
|
||||
void ShowImpl() override;
|
||||
void HideImpl() override;
|
||||
gfx::Rect GetBoundsInPixels() const override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) override;
|
||||
gfx::Point GetLocationOnScreenInPixels() const override;
|
||||
void SetCapture() override;
|
||||
void ReleaseCapture() override;
|
||||
@ -81,6 +82,14 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
|
||||
gfx::NativeCursor current_cursor_;
|
||||
gfx::Rect bounds_;
|
||||
|
||||
// |pending_local_surface_id_| and |pending_size_| are set when the
|
||||
// PlatformWindow instance is requested to adopt a new size (in
|
||||
// SetBoundsInPixels()). When the platform confirms the new size (by way of
|
||||
// OnBoundsChanged() callback), the LocalSurfaceId is set on the compositor,
|
||||
// by WindowTreeHost.
|
||||
viz::LocalSurfaceId pending_local_surface_id_;
|
||||
gfx::Size pending_size_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostPlatform);
|
||||
};
|
||||
|
||||
|
@ -358,6 +358,11 @@ void Compositor::SetScaleAndSize(float scale,
|
||||
bool device_scale_factor_changed = device_scale_factor_ != scale;
|
||||
device_scale_factor_ = scale;
|
||||
|
||||
if (size_ != size_in_pixel && local_surface_id.is_valid()) {
|
||||
// A new LocalSurfaceId must be set when the compositor size changes.
|
||||
DCHECK_NE(local_surface_id, host_->local_surface_id());
|
||||
}
|
||||
|
||||
if (!size_in_pixel.IsEmpty()) {
|
||||
size_ = size_in_pixel;
|
||||
host_->SetViewportSizeAndScale(size_in_pixel, scale, local_surface_id);
|
||||
|
@ -280,7 +280,8 @@ float DesktopWindowTreeHostMus::GetScaleFactor() const {
|
||||
}
|
||||
|
||||
void DesktopWindowTreeHostMus::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) {
|
||||
SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip));
|
||||
SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip),
|
||||
viz::LocalSurfaceId());
|
||||
}
|
||||
|
||||
bool DesktopWindowTreeHostMus::ShouldSendClientAreaToServer() const {
|
||||
@ -824,7 +825,8 @@ void DesktopWindowTreeHostMus::HideImpl() {
|
||||
}
|
||||
|
||||
void DesktopWindowTreeHostMus::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds_in_pixels) {
|
||||
const gfx::Rect& bounds_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
gfx::Rect final_bounds_in_pixels = bounds_in_pixels;
|
||||
if (GetBoundsInPixels().size() != bounds_in_pixels.size()) {
|
||||
gfx::Size size = bounds_in_pixels.size();
|
||||
@ -837,7 +839,8 @@ void DesktopWindowTreeHostMus::SetBoundsInPixels(
|
||||
final_bounds_in_pixels.set_size(size);
|
||||
}
|
||||
const gfx::Rect old_bounds_in_pixels = GetBoundsInPixels();
|
||||
WindowTreeHostMus::SetBoundsInPixels(final_bounds_in_pixels);
|
||||
WindowTreeHostMus::SetBoundsInPixels(final_bounds_in_pixels,
|
||||
local_surface_id);
|
||||
if (old_bounds_in_pixels.size() != final_bounds_in_pixels.size()) {
|
||||
SendClientAreaToServer();
|
||||
SendHitTestMaskToServer();
|
||||
|
@ -140,7 +140,8 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus
|
||||
// aura::WindowTreeHostMus:
|
||||
void ShowImpl() override;
|
||||
void HideImpl() override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds_in_pixels) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id) override;
|
||||
|
||||
// Accessor for DesktopNativeWidgetAura::content_window().
|
||||
aura::Window* content_window();
|
||||
|
@ -33,7 +33,8 @@ void DesktopWindowTreeHostPlatform::SetBoundsInDIP(
|
||||
const gfx::Rect& bounds_in_dip) {
|
||||
DCHECK_NE(0, device_scale_factor());
|
||||
SetBoundsInPixels(
|
||||
gfx::ConvertRectToPixel(device_scale_factor(), bounds_in_dip));
|
||||
gfx::ConvertRectToPixel(device_scale_factor(), bounds_in_dip),
|
||||
viz::LocalSurfaceId());
|
||||
}
|
||||
|
||||
void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) {
|
||||
|
@ -521,7 +521,14 @@ gfx::Rect DesktopWindowTreeHostWin::GetBoundsInPixels() const {
|
||||
return without_expansion;
|
||||
}
|
||||
|
||||
void DesktopWindowTreeHostWin::SetBoundsInPixels(const gfx::Rect& bounds) {
|
||||
void DesktopWindowTreeHostWin::SetBoundsInPixels(
|
||||
const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
// On Windows, the callers of SetBoundsInPixels() shouldn't need to (or be
|
||||
// able to) allocate LocalSurfaceId for the compositor. Aura itself should
|
||||
// allocate the new ids as needed, instead.
|
||||
DCHECK(!local_surface_id.is_valid());
|
||||
|
||||
// If the window bounds have to be expanded we need to subtract the
|
||||
// window_expansion_top_left_delta_ from the origin and add the
|
||||
// window_expansion_bottom_right_delta_ to the width and height
|
||||
|
@ -126,7 +126,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
|
||||
void ShowImpl() override;
|
||||
void HideImpl() override;
|
||||
gfx::Rect GetBoundsInPixels() const override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& bounds,
|
||||
const viz::LocalSurfaceId& local_surface_id =
|
||||
viz::LocalSurfaceId()) override;
|
||||
gfx::Point GetLocationOnScreenInPixels() const override;
|
||||
void SetCapture() override;
|
||||
void ReleaseCapture() override;
|
||||
|
@ -1199,7 +1199,13 @@ gfx::Rect DesktopWindowTreeHostX11::GetBoundsInPixels() const {
|
||||
}
|
||||
|
||||
void DesktopWindowTreeHostX11::SetBoundsInPixels(
|
||||
const gfx::Rect& requested_bounds_in_pixel) {
|
||||
const gfx::Rect& requested_bounds_in_pixel,
|
||||
const viz::LocalSurfaceId& local_surface_id) {
|
||||
// On desktop-x11, the callers of SetBoundsInPixels() shouldn't need to (or be
|
||||
// able to) allocate LocalSurfaceId for the compositor. Aura itself should
|
||||
// allocate the new ids as needed, instead.
|
||||
DCHECK(!local_surface_id.is_valid());
|
||||
|
||||
gfx::Rect bounds_in_pixels(requested_bounds_in_pixel.origin(),
|
||||
AdjustSize(requested_bounds_in_pixel.size()));
|
||||
bool origin_changed = bounds_in_pixels_.origin() != bounds_in_pixels.origin();
|
||||
@ -1251,7 +1257,7 @@ void DesktopWindowTreeHostX11::SetBoundsInPixels(
|
||||
if (origin_changed)
|
||||
native_widget_delegate_->AsWidget()->OnNativeWidgetMove();
|
||||
if (size_changed) {
|
||||
OnHostResizedInPixels(bounds_in_pixels.size());
|
||||
OnHostResizedInPixels(bounds_in_pixels.size(), local_surface_id);
|
||||
ResetWindowRegion();
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
|
||||
void ShowImpl() override;
|
||||
void HideImpl() override;
|
||||
gfx::Rect GetBoundsInPixels() const override;
|
||||
void SetBoundsInPixels(const gfx::Rect& requested_bounds_in_pixels) override;
|
||||
void SetBoundsInPixels(const gfx::Rect& requested_bounds_in_pixels,
|
||||
const viz::LocalSurfaceId& local_surface_id =
|
||||
viz::LocalSurfaceId()) override;
|
||||
gfx::Point GetLocationOnScreenInPixels() const override;
|
||||
void SetCapture() override;
|
||||
void ReleaseCapture() override;
|
||||
|
Reference in New Issue
Block a user