Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 GrSurfaceContextPriv_DEFINED |
| 9 | #define GrSurfaceContextPriv_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrSurfaceContext.h" |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 12 | |
| 13 | /** Class that adds methods to GrSurfaceContext that are only intended for use internal to |
| 14 | Skia. This class is purely a privileged window into GrSurfaceContext. It should never have |
| 15 | additional data members or virtual methods. */ |
| 16 | class GrSurfaceContextPriv { |
| 17 | public: |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 18 | GrRecordingContext* getContext() { return fSurfaceContext->fContext; } |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 19 | |
| 20 | private: |
Ben Wagner | 63fd760 | 2017-10-09 15:45:33 -0400 | [diff] [blame] | 21 | explicit GrSurfaceContextPriv(GrSurfaceContext* surfaceContext) |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 22 | : fSurfaceContext(surfaceContext) { |
| 23 | } |
| 24 | |
| 25 | GrSurfaceContextPriv(const GrSurfaceContextPriv&) {} // unimpl |
| 26 | GrSurfaceContextPriv& operator=(const GrSurfaceContextPriv&); // unimpl |
| 27 | |
| 28 | // No taking addresses of this type. |
| 29 | const GrSurfaceContextPriv* operator&() const; |
| 30 | GrSurfaceContextPriv* operator&(); |
| 31 | |
| 32 | GrSurfaceContext* fSurfaceContext; |
| 33 | |
| 34 | friend class GrSurfaceContext; // to construct/copy this type. |
| 35 | }; |
| 36 | |
| 37 | inline GrSurfaceContextPriv GrSurfaceContext::surfPriv() { |
| 38 | return GrSurfaceContextPriv(this); |
| 39 | } |
| 40 | |
| 41 | inline const GrSurfaceContextPriv GrSurfaceContext::surfPriv() const { |
| 42 | return GrSurfaceContextPriv(const_cast<GrSurfaceContext*>(this)); |
| 43 | } |
| 44 | |
| 45 | #endif |