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

Unified Diff: ui/aura/mus/window_port_mus.cc

Issue 2580063002: Mustash: Ensure surfaces submitted to Mus by WM and embedders contain Surfaces with embeded content. (Closed)
Patch Set: Created 4 years 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
« ui/aura/mus/window_port_mus.h ('K') | « ui/aura/mus/window_port_mus.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_port_mus.cc
diff --git a/ui/aura/mus/window_port_mus.cc b/ui/aura/mus/window_port_mus.cc
index da5774c1935d7a7a56b1a23f5c0734bb665636cc..874a1773d005ab324df11ef13c46e03e5aa7736c 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -4,6 +4,7 @@
#include "ui/aura/mus/window_port_mus.h"
+#include "cc/surfaces/surface_reference_factory.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/transient_window_client.h"
#include "ui/aura/mus/property_converter.h"
@@ -16,6 +17,43 @@
#include "ui/aura/window_property.h"
namespace aura {
+namespace {
+
+// TODO(mfomitchev, samans): Remove these stub classes once the SurfaceReference
+// work is complete.
+class StubSurfaceReference : public cc::SurfaceReferenceBase {
+ public:
+ StubSurfaceReference(scoped_refptr<const cc::SurfaceReferenceFactory> factory)
+ : cc::SurfaceReferenceBase(factory) {}
+
+ ~StubSurfaceReference() override { Destroy(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(StubSurfaceReference);
+};
+
+class StubSurfaceReferenceFactory : public cc::SurfaceReferenceFactory {
+ public:
+ StubSurfaceReferenceFactory() = default;
+
+ // cc::SurfaceReferenceFactory:
+ std::unique_ptr<cc::SurfaceReferenceBase> CreateReference(
+ cc::SurfaceReferenceOwner* owner,
+ const cc::SurfaceId& surface_id) const override {
+ return base::MakeUnique<StubSurfaceReference>(make_scoped_refptr(this));
+ }
+
+ protected:
+ ~StubSurfaceReferenceFactory() override = default;
+
+ private:
+ // cc::SurfaceReferenceFactory:
+ void DestroyReference(cc::SurfaceReferenceBase* surface_ref) const override {}
+
+ DISALLOW_COPY_AND_ASSIGN(StubSurfaceReferenceFactory);
+};
+
+} // namespace
WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
@@ -170,6 +208,57 @@ PropertyConverter* WindowPortMus::GetPropertyConverter() {
return window_tree_client_->delegate_->GetPropertyConverter();
}
+void WindowPortMus::UpdateSurfaceLayer(SurfaceInfo* surface_info) {
sky 2016/12/16 21:50:29 const SurfaceInfo?
mfomitchev 2016/12/23 00:03:49 Made it const reference.
+ if (!surface_info)
sky 2016/12/16 21:50:29 When and why would null be passed in?
mfomitchev 2016/12/23 00:03:49 It is called with null from WindowPortMus's destru
+ return;
+
+ if (!surface_layer_) {
+ surface_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_TEXTURED);
+ surface_layer_->SetVisible(true);
+ // The frame provided by the parent window->layer() needs to show through
+ // the surface layer.
+ surface_layer_->SetFillsBoundsOpaquely(false);
+
+ clipping_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_TEXTURED);
+ clipping_layer_->SetFillsBoundsOpaquely(false);
+
+ clipping_layer_->Add(surface_layer_.get());
+ window_->layer()->Add(clipping_layer_.get());
+
+ // Window's layer may contain content from this client (the embedder), e.g.
+ // this is the case with window decorations provided by Window Manager.
+ // This content should appear underneath the content of the embedded client.
+ window_->layer()->StackAtTop(clipping_layer_.get());
+
+ // We can't set this on window's layer, because that would clip the window
+ // shadow.
+ clipping_layer_->SetMasksToBounds(true);
+ }
+
+ // TODO(mfomitchev): Currently the frame size may not match the window size.
+ // In the future the surface id will be created by Ash (and used with the
+ // surface layer) when the window resize happens, which will ensure that the
+ // surface size matches the window size (unless a timeout occurs).
+ gfx::Size frame_size = surface_info->frame_size;
+ surface_layer_->SetBounds(
+ gfx::Rect(0, 0, frame_size.width(), frame_size.height()));
+ // Clip to window bounds.
+ clipping_layer_->SetBounds(
+ gfx::Rect(0, 0, window_->bounds().width(), window_->bounds().height()));
+
+ // TODO(mfomitchev, riajiang): Hopefully this is fixed after
+ // https://codereview.chromium.org/2547243002/ lands
+ float scale_factor = surface_info->device_scale_factor;
+ scale_factor = scale_factor ? scale_factor : 1;
+
+ // TODO(mfomitchev, samans): Get rid of Aura's SurfaceInfo.
+ cc::SurfaceInfo cc_surface_info(surface_info->surface_id, scale_factor,
+ frame_size);
+
+ surface_layer_->SetShowSurface(
+ cc_surface_info, make_scoped_refptr(new StubSurfaceReferenceFactory));
+}
+
Window* WindowPortMus::GetWindow() {
return window_;
}
@@ -255,10 +344,17 @@ void WindowPortMus::SetSurfaceIdFromServer(
}
}
WindowPortMus* parent = Get(window_->parent());
+ // TODO(mfomitchev): This is unused. We probably don't need this.
if (parent && parent->surface_id_handler_) {
parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_,
&surface_info);
}
+
+ // The fact that SetSurfaceIdFromServer was called means that this window
+ // corresponds to an embedded client. Update the surface layer dedicated to
+ // holding the client's content.
+ UpdateSurfaceLayer(surface_info.get());
+
surface_info_ = std::move(surface_info);
}
« ui/aura/mus/window_port_mus.h ('K') | « ui/aura/mus/window_port_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698