OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 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 #ifndef APP_SCOPED_HANDLE_GTK_H_ | |
6 #define APP_SCOPED_HANDLE_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include <gdk/gdk.h> | |
10 | |
11 // Wraps a GdkRegion. This class provides the same methods as ScopedGDIObject in | |
12 // scoped_handle_win. | |
13 class ScopedRegion { | |
14 public: | |
15 ScopedRegion() : region_(NULL) {} | |
16 explicit ScopedRegion(GdkRegion* region) : region_(region) {} | |
17 | |
18 ~ScopedRegion() { | |
19 Close(); | |
20 } | |
21 | |
22 void Set(GdkRegion* region) { | |
23 Close(); | |
24 | |
25 region_ = region; | |
26 } | |
27 | |
28 GdkRegion* Get() { | |
29 return region_; | |
30 } | |
31 | |
32 GdkRegion* release() { | |
33 GdkRegion* region = region_; | |
34 region_ = NULL; | |
35 return region; | |
36 } | |
37 | |
38 private: | |
39 void Close() { | |
40 if (region_) { | |
41 gdk_region_destroy(region_); | |
42 region_ = NULL; | |
43 } | |
44 } | |
45 | |
46 GdkRegion* region_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(ScopedRegion); | |
49 }; | |
50 | |
51 #endif // APP_SCOPED_HANDLE_GTK_H_ | |
OLD | NEW |