Disable overview mode by default.
[chromium-blink-merge.git] / ash / wm / boot_splash_screen_chromeos.cc
blob00743409ae5c600b40f57b83cfbbe9e716d1ab42
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
3 // found in the LICENSE file.
5 #include "ash/wm/boot_splash_screen_chromeos.h"
7 #include "third_party/skia/include/core/SkBitmap.h"
8 #include "ui/aura/root_window.h"
9 #include "ui/base/x/x11_util.h"
10 #include "ui/compositor/layer.h"
11 #include "ui/compositor/layer_type.h"
12 #include "ui/compositor/scoped_layer_animation_settings.h"
13 #include "ui/gfx/canvas.h"
15 namespace ash {
16 namespace internal {
18 // ui::LayerDelegate that copies the aura host window's content to a ui::Layer.
19 class BootSplashScreen::CopyHostContentLayerDelegate
20 : public ui::LayerDelegate {
21 public:
22 explicit CopyHostContentLayerDelegate(aura::RootWindow* root_window)
23 : root_window_(root_window) {
26 virtual ~CopyHostContentLayerDelegate() {}
28 // ui::LayerDelegate overrides:
29 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
30 // It'd be safer to copy the area to a canvas in the constructor and then
31 // copy from that canvas to this one here, but this appears to work (i.e. we
32 // only call this before we draw our first frame) and it saves us an extra
33 // copy.
34 // TODO(derat): Instead of copying the data, use GLX_EXT_texture_from_pixmap
35 // to create a zero-copy texture (when possible):
36 // https://codereview.chromium.org/10543125
37 ui::CopyAreaToCanvas(root_window_->GetAcceleratedWidget(),
38 gfx::Rect(root_window_->GetHostOrigin(), root_window_->GetHostSize()),
39 gfx::Point(), canvas);
42 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {}
44 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE {
45 return base::Closure();
48 private:
49 aura::RootWindow* root_window_; // not owned
51 DISALLOW_COPY_AND_ASSIGN(CopyHostContentLayerDelegate);
54 BootSplashScreen::BootSplashScreen(aura::RootWindow* root_window)
55 : layer_delegate_(new CopyHostContentLayerDelegate(root_window)),
56 layer_(new ui::Layer(ui::LAYER_TEXTURED)) {
57 layer_->set_delegate(layer_delegate_.get());
59 ui::Layer* root_layer = root_window->layer();
60 layer_->SetBounds(gfx::Rect(root_layer->bounds().size()));
61 root_layer->Add(layer_.get());
62 root_layer->StackAtTop(layer_.get());
65 BootSplashScreen::~BootSplashScreen() {
68 void BootSplashScreen::StartHideAnimation(base::TimeDelta duration) {
69 ui::ScopedLayerAnimationSettings settings(layer_->GetAnimator());
70 settings.SetTransitionDuration(duration);
71 settings.SetPreemptionStrategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
72 layer_->SetOpacity(0.0f);
75 } // namespace internal
76 } // namespace ash