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

Side by Side Diff: chrome/browser/chromeos/display/overscan_calibrator.cc

Issue 11195036: Overscan calibration UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 "chrome/browser/chromeos/display/overscan_calibrator.h"
6
7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "base/callback.h"
11 #include "chrome/browser/chromeos/display/display_preferences.h"
12 #include "ui/aura/window.h"
13 #include "ui/compositor/layer.h"
14 #include "ui/gfx/canvas.h"
15
16 namespace chromeos {
17
18 OverscanCalibrator::OverscanCalibrator(
19 const gfx::Display& target_display, const gfx::Insets& initial_insets)
20 : display_(target_display), insets_(initial_insets) {
21 aura::RootWindow* root = ash::Shell::GetInstance()->display_controller()->
22 GetRootWindowForDisplayId(display_.id());
23 ui::Layer* parent_layer = ash::Shell::GetContainer(
24 root, ash::internal::kShellWindowId_OverlayContainer)->layer();
25
26 calibration_layer_.reset(new ui::Layer());
27 calibration_layer_->SetOpacity(0.5f);
28 calibration_layer_->SetBounds(parent_layer->bounds());
29 calibration_layer_->set_delegate(this);
30 parent_layer->Add(calibration_layer_.get());
31 // The initial size of |inner_bounds_| has to be same as the root because the
32 // root size already shrinks due to the current overscan settings.
33 inner_bounds_ = parent_layer->bounds();
34 }
35
36 OverscanCalibrator::~OverscanCalibrator() {
37 }
38
39 void OverscanCalibrator::Commit() {
40 SetDisplayOverscan(display_, insets_);
41 }
42
43 void OverscanCalibrator::UpdateInsets(const gfx::Insets& insets) {
44 // Has to undo the old |insets_| in order to apply the new |insets|.
45 inner_bounds_.Inset(-insets_);
46 inner_bounds_.Inset(insets);
47 insets_ = insets;
48 calibration_layer_->SchedulePaint(calibration_layer_->bounds());
49 }
50
51 void OverscanCalibrator::OnPaintLayer(gfx::Canvas* canvas) {
52 static const SkColor transparent = SkColorSetARGB(0, 0, 0, 0);
53 canvas->FillRect(calibration_layer_->bounds(), SK_ColorBLACK);
54 canvas->FillRect(inner_bounds_, transparent, SkXfermode::kClear_Mode);
55 }
56
57 void OverscanCalibrator::OnDeviceScaleFactorChanged(
58 float device_scale_factor) {
59 // TODO(mukai): Cancel the overscan calibration when the device
60 // configuration has changed.
61 }
62
63 base::Closure OverscanCalibrator::PrepareForLayerBoundsChange() {
64 return base::Closure();
65 }
66
67 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/display/overscan_calibrator.h ('k') | chrome/browser/resources/options/chromeos/display_options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698