[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ui / gfx / win / scoped_set_map_mode.h
blob910837d109ce8f60bb80d0935addc818037b9687
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.
5 #ifndef UI_GFX_WIN_SCOPED_SET_MAP_MODE_H_
6 #define UI_GFX_WIN_SCOPED_SET_MAP_MODE_H_
8 #include <windows.h>
10 #include "base/basictypes.h"
11 #include "base/logging.h"
13 namespace gfx {
15 // Helper class for setting and restore the map mode on a DC.
16 class ScopedSetMapMode {
17 public:
18 ScopedSetMapMode(HDC hdc, int map_mode)
19 : hdc_(hdc),
20 old_map_mode_(SetMapMode(hdc, map_mode)) {
21 DCHECK(hdc_);
22 DCHECK_NE(map_mode, 0);
23 DCHECK_NE(old_map_mode_, 0);
26 ~ScopedSetMapMode() {
27 const int mode = SetMapMode(hdc_, old_map_mode_);
28 DCHECK_NE(mode, 0);
31 private:
32 HDC hdc_;
33 int old_map_mode_;
35 DISALLOW_COPY_AND_ASSIGN(ScopedSetMapMode);
38 } // namespace gfx
40 #endif // UI_GFX_WIN_SCOPED_SET_MAP_MODE_H_