Home | History | Annotate | Download | only in wm
      1 // Copyright (c) 2012 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.
      4 
      5 #include "ash/wm/system_background_controller.h"
      6 
      7 #include "ui/aura/root_window.h"
      8 #include "ui/compositor/layer.h"
      9 #include "ui/compositor/layer_type.h"
     10 
     11 namespace ash {
     12 namespace internal {
     13 
     14 namespace {
     15 
     16 #if defined(OS_CHROMEOS)
     17 // Background color used for the Chrome OS boot splash screen.
     18 const SkColor kChromeOsBootColor = SkColorSetARGB(0xff, 0xfe, 0xfe, 0xfe);
     19 #endif
     20 
     21 }  // namespace
     22 
     23 SystemBackgroundController::SystemBackgroundController(
     24     aura::RootWindow* root_window,
     25     SkColor color)
     26     : root_window_(root_window),
     27       layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)) {
     28   root_window_->AddObserver(this);
     29   layer_->SetColor(color);
     30 
     31   ui::Layer* root_layer = root_window_->layer();
     32   layer_->SetBounds(gfx::Rect(root_layer->bounds().size()));
     33   root_layer->Add(layer_.get());
     34   root_layer->StackAtBottom(layer_.get());
     35 }
     36 
     37 SystemBackgroundController::~SystemBackgroundController() {
     38   root_window_->RemoveObserver(this);
     39 }
     40 
     41 void SystemBackgroundController::SetColor(SkColor color) {
     42   layer_->SetColor(color);
     43 }
     44 
     45 void SystemBackgroundController::OnWindowBoundsChanged(
     46     aura::Window* root,
     47     const gfx::Rect& old_bounds,
     48     const gfx::Rect& new_bounds) {
     49   DCHECK_EQ(root_window_, root);
     50   layer_->SetBounds(gfx::Rect(root_window_->layer()->bounds().size()));
     51 }
     52 
     53 }  // namespace internal
     54 }  // namespace ash
     55