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 ScopedRegion()11ScopedRegion::ScopedRegion() : region_(NULL) {} 12 ScopedRegion(GdkRegion * region)13ScopedRegion::ScopedRegion(GdkRegion* region) : region_(region) {} 14 ~ScopedRegion()15ScopedRegion::~ScopedRegion() { 16 Close(); 17 } 18 Set(GdkRegion * region)19void ScopedRegion::Set(GdkRegion* region) { 20 Close(); 21 region_ = region; 22 } 23 Get()24GdkRegion* ScopedRegion::Get() { 25 return region_; 26 } 27 release()28GdkRegion* ScopedRegion::release() { 29 GdkRegion* region = region_; 30 region_ = NULL; 31 return region; 32 } 33 Close()34void ScopedRegion::Close() { 35 if (region_) { 36 gdk_region_destroy(region_); 37 region_ = NULL; 38 } 39 } 40 41 } // namespace ui 42