blob: 11390854b98e8b8647bad6ce4cf72246b633afcb [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
11#include "GrImageContext.h"
12
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 Phillips7e90be92019-02-15 12:22:59 -050025 bool explicitlyAllocateGPUResources() const {
26 return fContext->explicitlyAllocateGPUResources();
27 }
28
Robert Phillipsbb606772019-02-04 17:50:57 -050029 const GrCaps* caps() const { return fContext->caps(); }
Robert Phillipsa41c6852019-02-07 10:44:10 -050030 sk_sp<const GrCaps> refCaps() const;
Robert Phillipsbb606772019-02-04 17:50:57 -050031
Robert Phillipsa41c6852019-02-07 10:44:10 -050032 sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
33
34 GrImageContext* asImageContext() { return fContext->asImageContext(); }
35 GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
36 GrContext* asDirectContext() { return fContext->asDirectContext(); }
Robert Phillipsbb606772019-02-04 17:50:57 -050037
Robert Phillips4217ea72019-01-30 13:08:28 -050038 // from GrImageContext
Robert Phillipsa41c6852019-02-07 10:44:10 -050039 GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
40 const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
41
Robert Phillipsa9162df2019-02-11 14:12:03 -050042 bool abandoned() const { return fContext->abandoned(); }
43
Robert Phillipsa41c6852019-02-07 10:44:10 -050044 /** This is only useful for debug purposes */
45 SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
Robert Phillips4217ea72019-01-30 13:08:28 -050046
47private:
48 explicit GrImageContextPriv(GrImageContext* context) : fContext(context) {}
49 GrImageContextPriv(const GrImageContextPriv&); // unimpl
50 GrImageContextPriv& operator=(const GrImageContextPriv&); // unimpl
51
52 // No taking addresses of this type.
53 const GrImageContextPriv* operator&() const;
54 GrImageContextPriv* operator&();
55
56 GrImageContext* fContext;
57
58 friend class GrImageContext; // to construct/copy this type.
59};
60
61inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); }
62
63inline const GrImageContextPriv GrImageContext::priv () const {
64 return GrImageContextPriv(const_cast<GrImageContext*>(this));
65}
66
67#endif