• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef UI_GFX_SCOPED_SK_REGION_H_
6 #define UI_GFX_SCOPED_SK_REGION_H_
7 
8 #include "third_party/skia/include/core/SkRegion.h"
9 
10 namespace gfx {
11 
12 // Wraps an SkRegion.
13 class ScopedSkRegion {
14  public:
ScopedSkRegion()15   ScopedSkRegion() : region_(NULL) {}
ScopedSkRegion(SkRegion * region)16   explicit ScopedSkRegion(SkRegion* region) : region_(region) {}
17 
~ScopedSkRegion()18   ~ScopedSkRegion() {
19     delete region_;
20   }
21 
Set(SkRegion * region)22   void Set(SkRegion* region) {
23     delete region_;
24     region_ = region;
25   }
26 
Get()27   SkRegion* Get() {
28     return region_;
29   }
30 
release()31   SkRegion* release() {
32     SkRegion* region = region_;
33     region_ = NULL;
34     return region;
35   }
36 
37  private:
38   SkRegion* region_;
39 
40   DISALLOW_COPY_AND_ASSIGN(ScopedSkRegion);
41 };
42 
43 }  // namespace gfx
44 
45 #endif  // UI_GFX_SCOPED_SK_REGION_H_
46