blob: 0ef9cef9c564bfdbbf0a43359970d356ae669154 [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 GrImageContext_DEFINED
9#define GrImageContext_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/GrContext_Base.h"
12#include "include/private/GrSingleOwner.h"
Robert Phillips4217ea72019-01-30 13:08:28 -050013
14class GrImageContextPriv;
Robert Phillipsa41c6852019-02-07 10:44:10 -050015class GrProxyProvider;
Robert Phillips4217ea72019-01-30 13:08:28 -050016
Brian Salomon57f211b2019-08-21 15:21:09 -040017class GrImageContext : public GrContext_Base {
Robert Phillips4217ea72019-01-30 13:08:28 -050018public:
19 ~GrImageContext() override;
20
21 // Provides access to functions that aren't part of the public API.
22 GrImageContextPriv priv();
John Stilesec9b4aa2020-08-07 13:05:14 -040023 const GrImageContextPriv priv() const; // NOLINT(readability-const-return-type)
Robert Phillips4217ea72019-01-30 13:08:28 -050024
25protected:
26 friend class GrImageContextPriv; // for hidden functions
27
Adlai Hollere219d1c2020-06-02 11:23:16 -040028 GrImageContext(sk_sp<GrContextThreadSafeProxy>);
Robert Phillipsa41c6852019-02-07 10:44:10 -050029
Brian Salomon57f211b2019-08-21 15:21:09 -040030 SK_API virtual void abandonContext();
Greg Daniel6e35a002020-04-01 13:29:59 -040031 SK_API virtual bool abandoned();
Robert Phillipsa9162df2019-02-11 14:12:03 -050032
Robert Phillipsa41c6852019-02-07 10:44:10 -050033 GrProxyProvider* proxyProvider() { return fProxyProvider.get(); }
34 const GrProxyProvider* proxyProvider() const { return fProxyProvider.get(); }
35
36 /** This is only useful for debug purposes */
37 GrSingleOwner* singleOwner() const { return &fSingleOwner; }
Robert Phillips4217ea72019-01-30 13:08:28 -050038
39 GrImageContext* asImageContext() override { return this; }
40
41private:
Robert Phillipsa41c6852019-02-07 10:44:10 -050042 std::unique_ptr<GrProxyProvider> fProxyProvider;
43
44 // In debug builds we guard against improper thread handling
45 // This guard is passed to the GrDrawingManager and, from there to all the
46 // GrRenderTargetContexts. It is also passed to the GrResourceProvider and SkGpuDevice.
Robert Phillipsa9162df2019-02-11 14:12:03 -050047 mutable GrSingleOwner fSingleOwner;
Robert Phillipsa41c6852019-02-07 10:44:10 -050048
Robert Phillips4217ea72019-01-30 13:08:28 -050049 typedef GrContext_Base INHERITED;
50};
51
52#endif