2 * Copyright 2019 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "include/private/gpu/ganesh/GrContext_Base.h"
10 #include "include/gpu/ShaderErrorHandler.h"
11 #include "src/gpu/ganesh/GrBaseContextPriv.h"
12 #include "src/gpu/ganesh/GrCaps.h"
13 #include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
14 #include "src/gpu/ganesh/effects/GrSkSLFP.h"
16 GrContext_Base::GrContext_Base(sk_sp<GrContextThreadSafeProxy> proxy)
17 : fThreadSafeProxy(std::move(proxy)) {
20 GrContext_Base::~GrContext_Base() { }
22 bool GrContext_Base::init() {
23 SkASSERT(fThreadSafeProxy->isValid());
28 uint32_t GrContext_Base::contextID() const { return fThreadSafeProxy->priv().contextID(); }
29 GrBackendApi GrContext_Base::backend() const { return fThreadSafeProxy->priv().backend(); }
31 const GrContextOptions& GrContext_Base::options() const {
32 return fThreadSafeProxy->priv().options();
35 const GrCaps* GrContext_Base::caps() const { return fThreadSafeProxy->priv().caps(); }
36 sk_sp<const GrCaps> GrContext_Base::refCaps() const { return fThreadSafeProxy->priv().refCaps(); }
38 GrBackendFormat GrContext_Base::defaultBackendFormat(SkColorType skColorType,
39 GrRenderable renderable) const {
40 return fThreadSafeProxy->defaultBackendFormat(skColorType, renderable);
43 GrBackendFormat GrContext_Base::compressedBackendFormat(SkImage::CompressionType c) const {
44 return fThreadSafeProxy->compressedBackendFormat(c);
47 int GrContext_Base::maxSurfaceSampleCountForColorType(SkColorType colorType) const {
48 return fThreadSafeProxy->maxSurfaceSampleCountForColorType(colorType);
51 sk_sp<GrContextThreadSafeProxy> GrContext_Base::threadSafeProxy() { return fThreadSafeProxy; }
53 ///////////////////////////////////////////////////////////////////////////////////////////////////
54 sk_sp<const GrCaps> GrBaseContextPriv::refCaps() const {
55 return this->context()->refCaps();
58 GrContextOptions::ShaderErrorHandler* GrBaseContextPriv::getShaderErrorHandler() const {
59 const GrContextOptions& options(this->options());
60 return options.fShaderErrorHandler ? options.fShaderErrorHandler
61 : skgpu::DefaultShaderErrorHandler();