blob: ac2c9006c772c48c3c84b8bab383e68a7d46f766 [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
Adlai Hollerdced31f2021-02-19 12:33:46 -050013#include "include/gpu/GrContextThreadSafeProxy.h"
Robert Phillipsea3489a2021-08-02 13:10:57 -040014#include "src/gpu/GrBaseContextPriv.h"
Adlai Hollerdced31f2021-02-19 12:33:46 -050015
Robert Phillips4217ea72019-01-30 13:08:28 -050016/** 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. */
Robert Phillipsea3489a2021-08-02 13:10:57 -040019class GrImageContextPriv : public GrBaseContextPriv {
Robert Phillips4217ea72019-01-30 13:08:28 -050020public:
Robert Phillipsea3489a2021-08-02 13:10:57 -040021 GrImageContext* context() { return static_cast<GrImageContext*>(fContext); }
22 const GrImageContext* context() const { return static_cast<const GrImageContext*>(fContext); }
Robert Phillips4217ea72019-01-30 13:08:28 -050023
Robert Phillipsea3489a2021-08-02 13:10:57 -040024 bool abandoned() { return this->context()->abandoned(); }
Robert Phillipsa9162df2019-02-11 14:12:03 -050025
Adlai Hollerdced31f2021-02-19 12:33:46 -050026 static sk_sp<GrImageContext> MakeForPromiseImage(sk_sp<GrContextThreadSafeProxy> tsp) {
27 return GrImageContext::MakeForPromiseImage(std::move(tsp));
28 }
29
Robert Phillipsa41c6852019-02-07 10:44:10 -050030 /** This is only useful for debug purposes */
Robert Phillipsea3489a2021-08-02 13:10:57 -040031 SkDEBUGCODE(GrSingleOwner* singleOwner() const { return this->context()->singleOwner(); } )
32
33protected:
34 explicit GrImageContextPriv(GrImageContext* iContext) : GrBaseContextPriv(iContext) {}
Robert Phillips4217ea72019-01-30 13:08:28 -050035
36private:
John Stilesb35c3b82020-08-06 19:58:52 -040037 GrImageContextPriv(const GrImageContextPriv&) = delete;
38 GrImageContextPriv& operator=(const GrImageContextPriv&) = delete;
Robert Phillips4217ea72019-01-30 13:08:28 -050039
40 // No taking addresses of this type.
41 const GrImageContextPriv* operator&() const;
42 GrImageContextPriv* operator&();
43
Robert Phillips4217ea72019-01-30 13:08:28 -050044 friend class GrImageContext; // to construct/copy this type.
Robert Phillipsea3489a2021-08-02 13:10:57 -040045
46 using INHERITED = GrBaseContextPriv;
Robert Phillips4217ea72019-01-30 13:08:28 -050047};
48
49inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); }
50
John Stilesec9b4aa2020-08-07 13:05:14 -040051inline const GrImageContextPriv GrImageContext::priv () const { // NOLINT(readability-const-return-type)
Robert Phillips4217ea72019-01-30 13:08:28 -050052 return GrImageContextPriv(const_cast<GrImageContext*>(this));
53}
54
55#endif