blob: c264eaaf7a38532b61b23db16f0170afd9a5520d [file] [log] [blame]
Robert Phillips4217ea72019-01-30 13:08:28 -05001/*
2 * Copyright 2019 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 GrRecordingContextPriv_DEFINED
9#define GrRecordingContextPriv_DEFINED
10
11#include "GrRecordingContext.h"
12
13/** Class that exposes methods to GrRecordingContext that are only intended for use internal to
14 Skia. This class is purely a privileged window into GrRecordingContext. It should never have
15 additional data members or virtual methods. */
16class GrRecordingContextPriv {
17public:
18 // from GrContext_Base
Robert Phillipsfd0d9702019-02-01 10:19:42 -050019 uint32_t contextID() const { return fContext->contextID(); }
Robert Phillips4217ea72019-01-30 13:08:28 -050020
Robert Phillipsfe0963c2019-02-07 13:25:07 -050021 bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); }
22
Robert Phillipsc1541ae2019-02-04 12:05:37 -050023 const GrContextOptions& options() const { return fContext->options(); }
24
Robert Phillipsbb606772019-02-04 17:50:57 -050025 const GrCaps* caps() const { return fContext->caps(); }
Robert Phillipsa41c6852019-02-07 10:44:10 -050026 sk_sp<const GrCaps> refCaps() const;
Robert Phillipsbb606772019-02-04 17:50:57 -050027
Robert Phillipsa41c6852019-02-07 10:44:10 -050028 sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
29
30 GrImageContext* asImageContext() { return fContext->asImageContext(); }
31 GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
32 GrContext* asDirectContext() { return fContext->asDirectContext(); }
Robert Phillipsbb606772019-02-04 17:50:57 -050033
Robert Phillips4217ea72019-01-30 13:08:28 -050034 // from GrImageContext
Robert Phillipsa41c6852019-02-07 10:44:10 -050035 GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
36 const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
37
38 /** This is only useful for debug purposes */
39 SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
Robert Phillips4217ea72019-01-30 13:08:28 -050040
41 // from GrRecordingContext
Robert Phillipsd6841482019-02-08 10:29:20 -050042 sk_sp<GrOpMemoryPool> refOpMemoryPool();
43 GrOpMemoryPool* opMemoryPool() { return fContext->opMemoryPool(); }
44
45 GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
Robert Phillips4217ea72019-01-30 13:08:28 -050046
47private:
48 explicit GrRecordingContextPriv(GrRecordingContext* context) : fContext(context) {}
49 GrRecordingContextPriv(const GrRecordingContextPriv&); // unimpl
50 GrRecordingContextPriv& operator=(const GrRecordingContextPriv&); // unimpl
51
52 // No taking addresses of this type.
53 const GrRecordingContextPriv* operator&() const;
54 GrRecordingContextPriv* operator&();
55
56 GrRecordingContext* fContext;
57
58 friend class GrRecordingContext; // to construct/copy this type.
59};
60
61inline GrRecordingContextPriv GrRecordingContext::priv() { return GrRecordingContextPriv(this); }
62
63inline const GrRecordingContextPriv GrRecordingContext::priv () const {
64 return GrRecordingContextPriv(const_cast<GrRecordingContext*>(this));
65}
66
67#endif