Disable Vsync when Aero Glass is enabled.
[chromium-blink-merge.git] / ash / wm / boot_splash_screen_chromeos.cc
blobca862fa62181630c0a9634fb534a54ec80790919
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/aura/window.h"
10 #include "ui/base/x/x11_util.h"
11 #include "ui/compositor/layer.h"
12 #include "ui/compositor/layer_type.h"
13 #include "ui/compositor/scoped_layer_animation_settings.h"
14 #include "ui/gfx/canvas.h"
16 namespace ash {
17 namespace internal {
19 // ui::LayerDelegate that copies the aura host window's content to a ui::Layer.
20 class BootSplashScreen::CopyHostContentLayerDelegate
21 : public ui::LayerDelegate {
22 public:
23 explicit CopyHostContentLayerDelegate(aura::RootWindow* root_window)
24 : root_window_(root_window) {
27 virtual ~CopyHostContentLayerDelegate() {}
29 // ui::LayerDelegate overrides:
30 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
31 // It'd be safer to copy the area to a canvas in the constructor and then
32 // copy from that canvas to this one here, but this appears to work (i.e. we
33 // only call this before we draw our first frame) and it saves us an extra
34 // copy.
35 // TODO(derat): Instead of copying the data, use GLX_EXT_texture_from_pixmap
36 // to create a zero-copy texture (when possible):
37 // https://codereview.chromium.org/10543125
38 ui::CopyAreaToCanvas(root_window_->host()->GetAcceleratedWidget(),
39 root_window_->host()->GetBounds(), 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->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