bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrSurface.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 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: |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 20 | GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; } |
| 21 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 22 | private: |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 23 | explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {} |
| 24 | GrSurfacePriv(const GrSurfacePriv&); // unimpl |
| 25 | GrSurfacePriv& operator=(const GrSurfacePriv&); // unimpl |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 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 |