• 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 #include "include/gpu/GrContextThreadSafeProxy.h"
14 #include "src/gpu/GrBaseContextPriv.h"
15 
16 /** Class that exposes methods on GrImageContext that are only intended for use internal to Skia.
17     This class is purely a privileged window into GrImageContext. It should never have
18     additional data members or virtual methods. */
19 class GrImageContextPriv : public GrBaseContextPriv {
20 public:
context()21     GrImageContext* context() { return static_cast<GrImageContext*>(fContext); }
context()22     const GrImageContext* context() const { return static_cast<const GrImageContext*>(fContext); }
23 
abandoned()24     bool abandoned() { return this->context()->abandoned(); }
25 
MakeForPromiseImage(sk_sp<GrContextThreadSafeProxy> tsp)26     static sk_sp<GrImageContext> MakeForPromiseImage(sk_sp<GrContextThreadSafeProxy> tsp) {
27         return GrImageContext::MakeForPromiseImage(std::move(tsp));
28     }
29 
30 #ifdef SKIA_OHOS_SINGLE_OWNER
singleOwner()31     GrSingleOwner* singleOwner() const { return this->context()->singleOwner(); }
32 #else
33     /** This is only useful for debug purposes */
SkDEBUGCODE(GrSingleOwner * singleOwner ()const{ return this->context()->singleOwner(); } )34     SkDEBUGCODE(GrSingleOwner* singleOwner() const { return this->context()->singleOwner(); } )
35 #endif
36 
37 protected:
38     explicit GrImageContextPriv(GrImageContext* iContext) : GrBaseContextPriv(iContext) {}
39     // Required until C++17 copy elision
40     GrImageContextPriv(const GrImageContextPriv&) = default;
41 
42 private:
43     GrImageContextPriv& operator=(const GrImageContextPriv&) = delete;
44 
45     // No taking addresses of this type.
46     const GrImageContextPriv* operator&() const;
47     GrImageContextPriv* operator&();
48 
49     friend class GrImageContext; // to construct/copy this type.
50 
51     using INHERITED = GrBaseContextPriv;
52 };
53 
priv()54 inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); }
55 
priv()56 inline const GrImageContextPriv GrImageContext::priv () const {  // NOLINT(readability-const-return-type)
57     return GrImageContextPriv(const_cast<GrImageContext*>(this));
58 }
59 
60 #endif
61