blob: 324feef9d413d0327044e1ba64bcb52a8fa607a1 [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
11#include "GrContext_Base.h"
Robert Phillipsa41c6852019-02-07 10:44:10 -050012#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
17class SK_API GrImageContext : public GrContext_Base {
18public:
19 ~GrImageContext() override;
20
21 // Provides access to functions that aren't part of the public API.
22 GrImageContextPriv priv();
23 const GrImageContextPriv priv() const;
24
25protected:
26 friend class GrImageContextPriv; // for hidden functions
27
Robert Phillipsa41c6852019-02-07 10:44:10 -050028 GrImageContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
29
Robert Phillipsa9162df2019-02-11 14:12:03 -050030 virtual void abandonContext();
31 bool abandoned() const;
32
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;
Robert Phillipsa9162df2019-02-11 14:12:03 -050043 bool fAbandoned = false;
Robert Phillipsa41c6852019-02-07 10:44:10 -050044
45 // In debug builds we guard against improper thread handling
46 // This guard is passed to the GrDrawingManager and, from there to all the
47 // GrRenderTargetContexts. It is also passed to the GrResourceProvider and SkGpuDevice.
Robert Phillipsa9162df2019-02-11 14:12:03 -050048 mutable GrSingleOwner fSingleOwner;
Robert Phillipsa41c6852019-02-07 10:44:10 -050049
Robert Phillips4217ea72019-01-30 13:08:28 -050050 typedef GrContext_Base INHERITED;
51};
52
53#endif