Debian Codegraph @

src/gpu/ganesh/GrContext_Base.cpp

raw
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 #include "include/private/gpu/ganesh/GrContext_Base.h"
9
10 #include "include/gpu/ShaderErrorHandler.h"
11 #include "include/gpu/ganesh/GrBackendSurface.h"
12 #include "include/gpu/ganesh/GrContextOptions.h"
13 #include "include/gpu/ganesh/GrContextThreadSafeProxy.h"
14 #include "include/private/base/SkAssert.h"
15 #include "src/gpu/ganesh/GrBaseContextPriv.h"
16 #include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
17
18 #include <utility>
19
20 enum SkColorType : int;
21
22 GrContext_Base::GrContext_Base(sk_sp<GrContextThreadSafeProxy> proxy)
23 : fThreadSafeProxy(std::move(proxy)) {
24 }
25
26 GrContext_Base::~GrContext_Base() { }
27
28 bool GrContext_Base::init() {
29 SkASSERT(fThreadSafeProxy->isValid());
30
31 return true;
32 }
33
34 uint32_t GrContext_Base::contextID() const { return fThreadSafeProxy->priv().contextID(); }
35 GrBackendApi GrContext_Base::backend() const { return fThreadSafeProxy->priv().backend(); }
36
37 const GrContextOptions& GrContext_Base::options() const {
38 return fThreadSafeProxy->priv().options();
39 }
40
41 const GrCaps* GrContext_Base::caps() const { return fThreadSafeProxy->priv().caps(); }
42 sk_sp<const GrCaps> GrContext_Base::refCaps() const { return fThreadSafeProxy->priv().refCaps(); }
43
44 GrBackendFormat GrContext_Base::defaultBackendFormat(SkColorType skColorType,
45 GrRenderable renderable) const {
46 return fThreadSafeProxy->defaultBackendFormat(skColorType, renderable);
47 }
48
49 GrBackendFormat GrContext_Base::compressedBackendFormat(SkTextureCompressionType c) const {
50 return fThreadSafeProxy->compressedBackendFormat(c);
51 }
52
53 int GrContext_Base::maxSurfaceSampleCountForColorType(SkColorType colorType) const {
54 return fThreadSafeProxy->maxSurfaceSampleCountForColorType(colorType);
55 }
56
57 sk_sp<GrContextThreadSafeProxy> GrContext_Base::threadSafeProxy() { return fThreadSafeProxy; }
58
59 ///////////////////////////////////////////////////////////////////////////////////////////////////
60 sk_sp<const GrCaps> GrBaseContextPriv::refCaps() const {
61 return this->context()->refCaps();
62 }
63
64 GrContextOptions::ShaderErrorHandler* GrBaseContextPriv::getShaderErrorHandler() const {
65 const GrContextOptions& options(this->options());
66 return options.fShaderErrorHandler ? options.fShaderErrorHandler
67 : skgpu::DefaultShaderErrorHandler();
68 }