blob: 33d2aa7e4c583d243a14727aecf95e37554561fa [file] [log] [blame]
Robert Phillipse305cc1f2016-12-14 12:19:05 -05001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrSurfaceContext.h"
Robert Phillipse305cc1f2016-12-14 12:19:05 -050012
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. */
16class GrSurfaceContextPriv {
17public:
Robert Phillips69893702019-02-22 11:16:30 -050018 GrRecordingContext* getContext() { return fSurfaceContext->fContext; }
Robert Phillipse305cc1f2016-12-14 12:19:05 -050019
20private:
Ben Wagner63fd7602017-10-09 15:45:33 -040021 explicit GrSurfaceContextPriv(GrSurfaceContext* surfaceContext)
Robert Phillipse305cc1f2016-12-14 12:19:05 -050022 : 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
37inline GrSurfaceContextPriv GrSurfaceContext::surfPriv() {
38 return GrSurfaceContextPriv(this);
39}
40
41inline const GrSurfaceContextPriv GrSurfaceContext::surfPriv() const {
42 return GrSurfaceContextPriv(const_cast<GrSurfaceContext*>(this));
43}
44
45#endif