OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/wm/boot_splash_screen_chromeos.h" | 5 #include "ash/wm/boot_splash_screen_chromeos.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/aura/window_tree_host.h" | 9 #include "ui/aura/window_tree_host.h" |
10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
11 #include "ui/compositor/layer_type.h" | 11 #include "ui/compositor/layer_type.h" |
12 #include "ui/compositor/paint_recorder.h" | 12 #include "ui/compositor/paint_recorder.h" |
13 #include "ui/compositor/scoped_layer_animation_settings.h" | 13 #include "ui/compositor/scoped_layer_animation_settings.h" |
14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
15 | 15 |
16 #if defined(USE_X11) | 16 #if defined(USE_X11) |
17 #include "ui/base/x/x11_util.h" // nogncheck | 17 #include "ui/base/x/x11_util.h" // nogncheck |
18 #endif | 18 #endif |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 | 21 |
22 // ui::LayerDelegate that copies the aura host window's content to a ui::Layer. | 22 // ui::LayerDelegate that copies the aura host window's content to a ui::Layer. |
23 class BootSplashScreen::CopyHostContentLayerDelegate | 23 class BootSplashScreen::CopyHostContentLayerDelegate |
24 : public ui::LayerDelegate { | 24 : public ui::LayerDelegate { |
25 public: | 25 public: |
26 explicit CopyHostContentLayerDelegate(aura::WindowTreeHost* host) | 26 explicit CopyHostContentLayerDelegate(aura::WindowTreeHost* host) |
27 : host_(host) { | 27 #if defined(USE_X11) |
| 28 : host_(host) |
| 29 #endif |
| 30 { |
28 } | 31 } |
29 | 32 |
30 ~CopyHostContentLayerDelegate() override {} | 33 ~CopyHostContentLayerDelegate() override {} |
31 | 34 |
32 // ui::LayerDelegate overrides: | 35 // ui::LayerDelegate overrides: |
33 void OnPaintLayer(const ui::PaintContext& context) override { | 36 void OnPaintLayer(const ui::PaintContext& context) override { |
34 // It'd be safer to copy the area to a canvas in the constructor and then | 37 // It'd be safer to copy the area to a canvas in the constructor and then |
35 // copy from that canvas to this one here, but this appears to work (i.e. we | 38 // copy from that canvas to this one here, but this appears to work (i.e. we |
36 // only call this before we draw our first frame) and it saves us an extra | 39 // only call this before we draw our first frame) and it saves us an extra |
37 // copy. | 40 // copy. |
(...skipping 12 matching lines...) Expand all Loading... |
50 | 53 |
51 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} | 54 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
52 | 55 |
53 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 56 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
54 | 57 |
55 base::Closure PrepareForLayerBoundsChange() override { | 58 base::Closure PrepareForLayerBoundsChange() override { |
56 return base::Closure(); | 59 return base::Closure(); |
57 } | 60 } |
58 | 61 |
59 private: | 62 private: |
| 63 #if defined(USE_X11) |
60 aura::WindowTreeHost* host_; // not owned | 64 aura::WindowTreeHost* host_; // not owned |
| 65 #endif |
61 | 66 |
62 DISALLOW_COPY_AND_ASSIGN(CopyHostContentLayerDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(CopyHostContentLayerDelegate); |
63 }; | 68 }; |
64 | 69 |
65 BootSplashScreen::BootSplashScreen(aura::WindowTreeHost* host) | 70 BootSplashScreen::BootSplashScreen(aura::WindowTreeHost* host) |
66 : layer_delegate_(new CopyHostContentLayerDelegate(host)), | 71 : layer_delegate_(new CopyHostContentLayerDelegate(host)), |
67 layer_(new ui::Layer(ui::LAYER_TEXTURED)) { | 72 layer_(new ui::Layer(ui::LAYER_TEXTURED)) { |
68 layer_->set_delegate(layer_delegate_.get()); | 73 layer_->set_delegate(layer_delegate_.get()); |
69 | 74 |
70 ui::Layer* root_layer = host->window()->layer(); | 75 ui::Layer* root_layer = host->window()->layer(); |
71 layer_->SetBounds(gfx::Rect(host->window()->bounds().size())); | 76 layer_->SetBounds(gfx::Rect(host->window()->bounds().size())); |
72 root_layer->Add(layer_.get()); | 77 root_layer->Add(layer_.get()); |
73 root_layer->StackAtTop(layer_.get()); | 78 root_layer->StackAtTop(layer_.get()); |
74 } | 79 } |
75 | 80 |
76 BootSplashScreen::~BootSplashScreen() { | 81 BootSplashScreen::~BootSplashScreen() { |
77 } | 82 } |
78 | 83 |
79 void BootSplashScreen::StartHideAnimation(base::TimeDelta duration) { | 84 void BootSplashScreen::StartHideAnimation(base::TimeDelta duration) { |
80 ui::ScopedLayerAnimationSettings settings(layer_->GetAnimator()); | 85 ui::ScopedLayerAnimationSettings settings(layer_->GetAnimator()); |
81 settings.SetTransitionDuration(duration); | 86 settings.SetTransitionDuration(duration); |
82 settings.SetPreemptionStrategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 87 settings.SetPreemptionStrategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
83 layer_->SetOpacity(0.0f); | 88 layer_->SetOpacity(0.0f); |
84 } | 89 } |
85 | 90 |
86 } // namespace ash | 91 } // namespace ash |
OLD | NEW |