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

Unified Diff: ash/wm/drag_window_controller.cc

Issue 1992853002: Create a LayerDelegate for recreated layers to draw when their content is invalidated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: ash/wm/drag_window_controller.cc
diff --git a/ash/wm/drag_window_controller.cc b/ash/wm/drag_window_controller.cc
index 6d85f4eceb5f30471cccc2f195196ec50c637618..5bda05e5376c56f43b0c7933031d7cbcd361e0a9 100644
--- a/ash/wm/drag_window_controller.cc
+++ b/ash/wm/drag_window_controller.cc
@@ -27,10 +27,40 @@
#include "ui/wm/core/window_util.h"
namespace ash {
+namespace {
+
+class DragWindowLayerDelegate : public ui::LayerDelegate {
sky 2016/05/19 20:06:49 Description
oshima 2016/05/19 23:32:21 Done.
+ public:
+ DragWindowLayerDelegate(ui::LayerDelegate* delegate)
sky 2016/05/19 20:06:49 How do you know the original delegate remains vali
sky 2016/05/19 20:06:49 explicit
oshima 2016/05/19 23:32:21 You're right. The only way to check, without intro
+ : original_delegate_(delegate) {}
+ ~DragWindowLayerDelegate() override {}
+
+ private:
+ // ui:LLayerDelegate:
+ void OnPaintLayer(const ui::PaintContext& context) override {
+ original_delegate_->OnPaintLayer(context);
+ }
+ void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
+ void OnDeviceScaleFactorChanged(float device_scale_factor) override {
+ // Don't tell the original delegate about device scale factor change
+ // on cloned layer because the original layer is still on the same display.
+ }
+ base::Closure PrepareForLayerBoundsChange() override {
+ return base::Closure();
+ }
+
+ ui::LayerDelegate* original_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(DragWindowLayerDelegate);
+};
+
+} // namespace
// This keeps tack of the drag window's state. It creates/destory/updates bounds
// and opacity based on the current bounds.
-class DragWindowController::DragWindowDetails : public aura::WindowDelegate {
+class DragWindowController::DragWindowDetails
+ : public aura::WindowDelegate,
+ public ::wm::LayerDelegateFactory {
public:
DragWindowDetails(const display::Display& display,
aura::Window* original_window)
@@ -109,11 +139,7 @@ class DragWindowController::DragWindowDetails : public aura::WindowDelegate {
void RecreateWindowLayers(aura::Window* original_window) {
DCHECK(!layer_owner_.get());
- layer_owner_ = ::wm::RecreateLayers(original_window);
- // TODO(oshima): Recreated child layers may not have been painted
- // yet, and may not be able to paint to because it does not have
- // its original delegate.
- layer_owner_->root()->set_delegate(original_window->layer()->delegate());
+ layer_owner_ = ::wm::RecreateLayers(original_window, this);
// Place the layer at (0, 0) of the DragWindowController's window.
gfx::Rect layer_bounds = layer_owner_->root()->bounds();
layer_bounds.set_origin(gfx::Point(0, 0));
@@ -131,6 +157,14 @@ class DragWindowController::DragWindowDetails : public aura::WindowDelegate {
}
// aura::WindowDelegate:
+ ui::LayerDelegate* CreateDelegate(ui::LayerDelegate* delegate) override {
+ DragWindowLayerDelegate* new_delegate =
+ new DragWindowLayerDelegate(delegate);
+ delegates_.push_back(base::WrapUnique(new_delegate));
+ return new_delegate;
+ }
+
+ // aura::WindowDelegate:
gfx::Size GetMinimumSize() const override { return gfx::Size(); }
gfx::Size GetMaximumSize() const override { return gfx::Size(); }
void OnBoundsChanged(const gfx::Rect& old_bounds,
@@ -163,6 +197,8 @@ class DragWindowController::DragWindowDetails : public aura::WindowDelegate {
aura::Window* drag_window_ = nullptr; // Owned by the container.
+ std::vector<std::unique_ptr<DragWindowLayerDelegate>> delegates_;
+
// The copy of window_->layer() and its descendants.
std::unique_ptr<ui::LayerTreeOwner> layer_owner_;

Powered by Google App Engine
This is Rietveld 408576698