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