Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrContext_Base.h
Go to the documentation of this file.
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 GrContext_Base_DEFINED
9#define GrContext_Base_DEFINED
10
12#include "include/gpu/GrTypes.h"
14
15#include <cstdint>
16
18class GrCaps;
20class GrDirectContext;
21class GrImageContext;
23enum SkColorType : int;
25struct GrContextOptions;
26class GrBackendFormat;
27
28class GrContext_Base : public SkRefCnt {
29public:
30 ~GrContext_Base() override;
31
32 /*
33 * Safely downcast to a GrDirectContext.
34 */
35 virtual GrDirectContext* asDirectContext() { return nullptr; }
36
37 /*
38 * The 3D API backing this context
39 */
41
42 /*
43 * Retrieve the default GrBackendFormat for a given SkColorType and renderability.
44 * It is guaranteed that this backend format will be the one used by the GrContext
45 * SkColorType and GrSurfaceCharacterization-based createBackendTexture methods.
46 *
47 * The caller should check that the returned format is valid.
48 */
50
52
53 /**
54 * Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA
55 * rendering is supported for the color type. 0 is returned if rendering to this color type
56 * is not supported at all.
57 */
59
60 // TODO: When the public version is gone, rename to refThreadSafeProxy and add raw ptr ver.
62
63 // Provides access to functions that aren't part of the public API.
65 const GrBaseContextPriv priv() const; // NOLINT(readability-const-return-type)
66
67protected:
68 friend class GrBaseContextPriv; // for hidden functions
69
71
72 virtual bool init();
73
74 /**
75 * An identifier for this context. The id is used by all compatible contexts. For example,
76 * if SkImages are created on one thread using an image creation context, then fed into a
77 * DDL Recorder on second thread (which has a recording context) and finally replayed on
78 * a third thread with a direct context, then all three contexts will report the same id.
79 * It is an error for an image to be used with contexts that report different ids.
80 */
81 uint32_t contextID() const;
82
83 bool matches(GrContext_Base* candidate) const {
84 return candidate && candidate->contextID() == this->contextID();
85 }
86
87 /*
88 * The options in effect for this context
89 */
90 const GrContextOptions& options() const;
91
92 const GrCaps* caps() const;
94
95 virtual GrImageContext* asImageContext() { return nullptr; }
96 virtual GrRecordingContext* asRecordingContext() { return nullptr; }
97
99
100private:
101 using INHERITED = SkRefCnt;
102};
103
104#endif
GrBackendApi
Definition GrTypes.h:95
#define SK_API
Definition SkAPI.h:35
SkColorType
Definition SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
Type::kYUV Type::kRGBA() int(0.7 *637)
virtual GrDirectContext * asDirectContext()
uint32_t contextID() const
const GrCaps * caps() const
GrBaseContextPriv priv()
SK_API GrBackendApi backend() const
sk_sp< GrContextThreadSafeProxy > threadSafeProxy()
sk_sp< const GrCaps > refCaps() const
virtual GrRecordingContext * asRecordingContext()
bool matches(GrContext_Base *candidate) const
~GrContext_Base() override
SK_API GrBackendFormat defaultBackendFormat(SkColorType, GrRenderable) const
SK_API GrBackendFormat compressedBackendFormat(SkTextureCompressionType) const
virtual bool init()
sk_sp< GrContextThreadSafeProxy > fThreadSafeProxy
const GrContextOptions & options() const
SK_API int maxSurfaceSampleCountForColorType(SkColorType colorType) const
virtual GrImageContext * asImageContext()
Renderable
Definition GpuTypes.h:69