1 | /* |
2 | * Copyright 2014 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef GrSurfacePriv_DEFINED |
9 | #define GrSurfacePriv_DEFINED |
10 | |
11 | #include "src/gpu/GrSurface.h" |
12 | |
13 | /** Class that adds methods to GrSurface that are only intended for use internal to Skia. |
14 | This class is purely a privileged window into GrSurface. It should never have additional data |
15 | members or virtual methods. |
16 | Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and |
17 | implemented privately in GrSurface with a inline public method here). */ |
18 | class GrSurfacePriv { |
19 | public: |
20 | GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; } |
21 | |
22 | private: |
23 | explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {} |
24 | GrSurfacePriv(const GrSurfacePriv&); // unimpl |
25 | GrSurfacePriv& operator=(const GrSurfacePriv&); // unimpl |
26 | |
27 | // No taking addresses of this type. |
28 | const GrSurfacePriv* operator&() const; |
29 | GrSurfacePriv* operator&(); |
30 | |
31 | GrSurface* fSurface; |
32 | |
33 | friend class GrSurface; // to construct/copy this type. |
34 | }; |
35 | |
36 | inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); } |
37 | |
38 | inline const GrSurfacePriv GrSurface::surfacePriv() const { |
39 | return GrSurfacePriv(const_cast<GrSurface*>(this)); |
40 | } |
41 | |
42 | #endif |
43 | |