• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "include/private/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. */
16 class GrImageContextPriv {
17 public:
18     // from GrContext_Base
contextID()19     uint32_t contextID() const { return fContext->contextID(); }
20 
matches(GrContext_Base * candidate)21     bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); }
22 
options()23     const GrContextOptions& options() const { return fContext->options(); }
24 
caps()25     const GrCaps* caps() const { return fContext->caps(); }
26     sk_sp<const GrCaps> refCaps() const;
27 
28     sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
29 
asImageContext()30     GrImageContext* asImageContext() { return fContext->asImageContext(); }
asRecordingContext()31     GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
asDirectContext()32     GrContext* asDirectContext() { return fContext->asDirectContext(); }
33 
34     // from GrImageContext
proxyProvider()35     GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
proxyProvider()36     const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
37 
abandoned()38     bool abandoned() const { return fContext->abandoned(); }
39 
40     /** This is only useful for debug purposes */
SkDEBUGCODE(GrSingleOwner * singleOwner ()const{ return fContext->singleOwner(); } )41     SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
42 
43 private:
44     explicit GrImageContextPriv(GrImageContext* context) : fContext(context) {}
45     GrImageContextPriv(const GrImageContextPriv&); // unimpl
46     GrImageContextPriv& operator=(const GrImageContextPriv&); // unimpl
47 
48     // No taking addresses of this type.
49     const GrImageContextPriv* operator&() const;
50     GrImageContextPriv* operator&();
51 
52     GrImageContext* fContext;
53 
54     friend class GrImageContext; // to construct/copy this type.
55 };
56 
priv()57 inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); }
58 
priv()59 inline const GrImageContextPriv GrImageContext::priv () const {
60     return GrImageContextPriv(const_cast<GrImageContext*>(this));
61 }
62 
63 #endif
64