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

Side by Side Diff: ui/aura/mus/client_surface_embedder.cc

Issue 2797263002: Aura-Mus: Implement gutter in the embedder. (Closed)
Patch Set: Updated test Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/mus/client_surface_embedder.h" 5 #include "ui/aura/mus/client_surface_embedder.h"
6 6
7 #include "cc/surfaces/surface_reference_factory.h" 7 #include "cc/surfaces/surface_reference_factory.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 9
10 namespace aura { 10 namespace aura {
(...skipping 12 matching lines...) Expand all
23 return base::Closure(); 23 return base::Closure();
24 } 24 }
25 25
26 protected: 26 protected:
27 ~StubSurfaceReferenceFactory() override = default; 27 ~StubSurfaceReferenceFactory() override = default;
28 28
29 DISALLOW_COPY_AND_ASSIGN(StubSurfaceReferenceFactory); 29 DISALLOW_COPY_AND_ASSIGN(StubSurfaceReferenceFactory);
30 }; 30 };
31 } // namespace 31 } // namespace
32 32
33 ClientSurfaceEmbedder::ClientSurfaceEmbedder(Window* window) : window_(window) { 33 ClientSurfaceEmbedder::ClientSurfaceEmbedder(
34 Window* window,
35 const gfx::Insets& client_area_insets)
36 : window_(window), client_area_insets_(client_area_insets) {
34 surface_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_TEXTURED); 37 surface_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_TEXTURED);
35 surface_layer_->SetVisible(true); 38 surface_layer_->SetMasksToBounds(true);
36 // The frame provided by the parent window->layer() needs to show through 39 // The frame provided by the parent window->layer() needs to show through
37 // the surface layer. 40 // the surface layer.
38 surface_layer_->SetFillsBoundsOpaquely(false); 41 surface_layer_->SetFillsBoundsOpaquely(false);
39 42
40 clip_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_NOT_DRAWN); 43 window_->layer()->Add(surface_layer_.get());
41 clip_layer_->SetFillsBoundsOpaquely(false);
42
43 clip_layer_->Add(surface_layer_.get());
44 window_->layer()->Add(clip_layer_.get());
45 44
46 // Window's layer may contain content from this client (the embedder), e.g. 45 // Window's layer may contain content from this client (the embedder), e.g.
47 // this is the case with window decorations provided by Window Manager. 46 // this is the case with window decorations provided by Window Manager.
48 // This content should appear underneath the content of the embedded client. 47 // This content should appear underneath the content of the embedded client.
49 window_->layer()->StackAtTop(clip_layer_.get()); 48 window_->layer()->StackAtTop(surface_layer_.get());
50
51 // We can't set this on window's layer, because that would clip the window
52 // shadow.
53 clip_layer_->SetMasksToBounds(true);
54 } 49 }
55 50
56 ClientSurfaceEmbedder::~ClientSurfaceEmbedder() = default; 51 ClientSurfaceEmbedder::~ClientSurfaceEmbedder() = default;
57 52
58 void ClientSurfaceEmbedder::SetPrimarySurfaceInfo( 53 void ClientSurfaceEmbedder::SetPrimarySurfaceInfo(
59 const cc::SurfaceInfo& surface_info) { 54 const cc::SurfaceInfo& surface_info) {
60 // TODO(mfomitchev): Currently the frame size may not match the window size.
61 // In the future the surface id will be created by Ash (and used with the
62 // surface layer) when the window resize happens, which will ensure that the
63 // surface size matches the window size (unless a timeout occurs).
64 gfx::Size frame_size = surface_info.size_in_pixels();
65 surface_layer_->SetBounds(
66 gfx::Rect(0, 0, frame_size.width(), frame_size.height()));
67 // Clip to window bounds.
68 clip_layer_->SetBounds(
69 gfx::Rect(0, 0, window_->bounds().width(), window_->bounds().height()));
70
71 surface_layer_->SetShowPrimarySurface( 55 surface_layer_->SetShowPrimarySurface(
72 surface_info, make_scoped_refptr(new StubSurfaceReferenceFactory)); 56 surface_info, make_scoped_refptr(new StubSurfaceReferenceFactory));
57 surface_layer_->SetBounds(gfx::Rect(window_->bounds().size()));
73 } 58 }
74 59
75 void ClientSurfaceEmbedder::SetFallbackSurfaceInfo( 60 void ClientSurfaceEmbedder::SetFallbackSurfaceInfo(
76 const cc::SurfaceInfo& surface_info) { 61 const cc::SurfaceInfo& surface_info) {
77 surface_layer_->SetFallbackSurface(surface_info); 62 surface_layer_->SetFallbackSurface(surface_info);
63 UpdateSizeAndGutters();
64 }
65
66 void ClientSurfaceEmbedder::UpdateSizeAndGutters() {
67 surface_layer_->SetBounds(gfx::Rect(window_->bounds().size()));
68 gfx::Size fallback_surface_size(
69 surface_layer_->GetFallbackSurfaceInfo()
70 ? surface_layer_->GetFallbackSurfaceInfo()->size_in_pixels()
sadrul 2017/04/07 13:07:33 Add a TODO here for high-dpi
Fady Samuel 2017/04/07 15:27:25 Done.
71 : gfx::Size());
72 gfx::Rect window_bounds(window_->bounds());
73 if (fallback_surface_size.width() < window_bounds.width()) {
74 right_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
sadrul 2017/04/07 13:07:33 MakeUnique
Fady Samuel 2017/04/07 15:27:25 Done.
75 right_gutter_->SetColor(SK_ColorWHITE);
sadrul 2017/04/07 13:07:33 TODO for the color?
Fady Samuel 2017/04/07 15:27:25 Done.
76 int width = window_bounds.width() - fallback_surface_size.width();
77 // The right gutter also includes the bottom-right corner, if necessary.
78 int height = window_bounds.height() - client_area_insets_.height();
79 right_gutter_->SetBounds(
80 gfx::Rect(client_area_insets_.left() + fallback_surface_size.width(),
81 client_area_insets_.top(), width, height));
82 window_->layer()->Add(right_gutter_.get());
83 } else {
84 right_gutter_.reset();
85 }
86
87 // Only create
sadrul 2017/04/07 13:07:33 Finish the c
Fady Samuel 2017/04/07 15:27:25 Done.
88 if (!fallback_surface_size.IsEmpty() &&
sadrul 2017/04/07 13:07:33 Check for empty size before the right gutter and r
Fady Samuel 2017/04/07 15:27:25 Can't I want to make sure that the surface layer's
89 fallback_surface_size.height() < window_bounds.height()) {
90 bottom_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
91 bottom_gutter_->SetColor(SK_ColorWHITE);
92 int width = fallback_surface_size.width();
93 int height = window_bounds.height() - fallback_surface_size.height();
94 bottom_gutter_->SetBounds(
95 gfx::Rect(0, fallback_surface_size.height(), width, height));
96 window_->layer()->Add(bottom_gutter_.get());
97 } else {
98 bottom_gutter_.reset();
99 }
100 window_->layer()->StackAtTop(surface_layer_.get());
78 } 101 }
79 102
80 } // namespace aura 103 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698