- add sources.
[platform/framework/web/crosswalk.git] / src / ui / base / gtk / scoped_region.cc
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 "ui/base/gtk/scoped_region.h"
6
7 #include <gdk/gdk.h>
8
9 namespace ui {
10
11 ScopedRegion::ScopedRegion() : region_(NULL) {}
12
13 ScopedRegion::ScopedRegion(GdkRegion* region) : region_(region) {}
14
15 ScopedRegion::~ScopedRegion() {
16   Close();
17 }
18
19 void ScopedRegion::Set(GdkRegion* region) {
20   Close();
21   region_ = region;
22 }
23
24 GdkRegion* ScopedRegion::Get() {
25   return region_;
26 }
27
28 GdkRegion* ScopedRegion::release() {
29   GdkRegion* region = region_;
30   region_ = NULL;
31   return region;
32 }
33
34 void ScopedRegion::Close() {
35   if (region_) {
36     gdk_region_destroy(region_);
37     region_ = NULL;
38   }
39 }
40
41 }  // namespace ui