blob: aa7c4c3aa1aadb566a372cd7233f2193684535c9 [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 GrImageContextPriv_DEFINED
9#define GrImageContextPriv_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/GrImageContext.h"
Robert Phillips4217ea72019-01-30 13:08:28 -050012
13/** Class that exposes methods on GrImageContext that are only intended for use internal to Skia.
14 This class is purely a privileged window into GrImageContext. It should never have
15 additional data members or virtual methods. */
16class GrImageContextPriv {
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 GrImageContext* asImageContext() { return fContext->asImageContext(); }
29 GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
Robert Phillipsbb606772019-02-04 17:50:57 -050030
Robert Phillips4217ea72019-01-30 13:08:28 -050031 // from GrImageContext
Robert Phillipsa41c6852019-02-07 10:44:10 -050032 GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
33 const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
34
Robert Phillipsa9162df2019-02-11 14:12:03 -050035 bool abandoned() const { return fContext->abandoned(); }
36
Robert Phillipsa41c6852019-02-07 10:44:10 -050037 /** This is only useful for debug purposes */
38 SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
Robert Phillips4217ea72019-01-30 13:08:28 -050039
40private:
41 explicit GrImageContextPriv(GrImageContext* context) : fContext(context) {}
John Stilesb35c3b82020-08-06 19:58:52 -040042 GrImageContextPriv(const GrImageContextPriv&) = delete;
43 GrImageContextPriv& operator=(const GrImageContextPriv&) = delete;
Robert Phillips4217ea72019-01-30 13:08:28 -050044
45 // No taking addresses of this type.
46 const GrImageContextPriv* operator&() const;
47 GrImageContextPriv* operator&();
48
49 GrImageContext* fContext;
50
51 friend class GrImageContext; // to construct/copy this type.
52};
53
54inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); }
55
56inline const GrImageContextPriv GrImageContext::priv () const {
57 return GrImageContextPriv(const_cast<GrImageContext*>(this));
58}
59
60#endif