aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSurfaceContextPriv.h
blob: 4a45f8f9b84bdba3c887aa3f4738ab3220e53c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrSurfaceContextPriv_DEFINED
#define GrSurfaceContextPriv_DEFINED

#include "GrSurfaceContext.h"

/** Class that adds methods to GrSurfaceContext that are only intended for use internal to
    Skia. This class is purely a privileged window into GrSurfaceContext. It should never have
    additional data members or virtual methods. */
class GrSurfaceContextPriv {
public:
    GrContext* getContext() { return fSurfaceContext->fContext; }

private:
    explicit GrSurfaceContextPriv(GrSurfaceContext* surfaceContext)
        : fSurfaceContext(surfaceContext) {
    }

    GrSurfaceContextPriv(const GrSurfaceContextPriv&) {} // unimpl
    GrSurfaceContextPriv& operator=(const GrSurfaceContextPriv&); // unimpl

    // No taking addresses of this type.
    const GrSurfaceContextPriv* operator&() const;
    GrSurfaceContextPriv* operator&();

    GrSurfaceContext* fSurfaceContext;

    friend class GrSurfaceContext; // to construct/copy this type.
};

inline GrSurfaceContextPriv GrSurfaceContext::surfPriv() {
    return GrSurfaceContextPriv(this);
}

inline const GrSurfaceContextPriv GrSurfaceContext::surfPriv() const {
    return GrSurfaceContextPriv(const_cast<GrSurfaceContext*>(this));
}

#endif