Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrGLContext.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2013 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
9
12
13#ifdef SK_BUILD_FOR_ANDROID
14#include <sys/system_properties.h>
15#endif
16
17////////////////////////////////////////////////////////////////////////////////
18
19std::unique_ptr<GrGLContext> GrGLContext::Make(sk_sp<const GrGLInterface> interface,
21 if (!interface->validate()) {
22 return nullptr;
23 }
24
27 if (args.fDriverInfo.fVersion == GR_GL_INVALID_VER) {
28 return nullptr;
29 }
30
31 if (!GrGLGetGLSLGeneration(args.fDriverInfo, &args.fGLSLGeneration)) {
32 return nullptr;
33 }
34
35 /*
36 * Qualcomm drivers for the 3xx series have a horrendous bug with some drivers. Though they
37 * claim to support GLES 3.00, some perfectly valid GLSL300 shaders will only compile with
38 * #version 100, and will fail to compile with #version 300 es. In the long term, we
39 * need to lock this down to a specific driver version.
40 * ?????/2019 - Qualcomm has fixed this for Android O+ devices (API 26+)
41 * ?????/2015 - This bug is still present in Lollipop pre-mr1
42 * 06/18/2015 - This bug does not affect the nexus 6 (which has an Adreno 4xx).
43 */
44#ifdef SK_BUILD_FOR_ANDROID
45 if (!options.fDisableDriverCorrectnessWorkarounds &&
46 args.fDriverInfo.fRenderer == GrGLRenderer::kAdreno3xx) {
47 char androidAPIVersion[PROP_VALUE_MAX];
48 int strLength = __system_property_get("ro.build.version.sdk", androidAPIVersion);
49 if (strLength == 0 || atoi(androidAPIVersion) < 26) {
50 args.fGLSLGeneration = SkSL::GLSLGeneration::k100es;
51 }
52 }
53#endif
54
55 // Many ES3 drivers only advertise the ES2 image_external extension, but support the _essl3
56 // extension, and require that it be enabled to work with ESSL3. Other devices require the ES2
57 // extension to be enabled, even when using ESSL3. Some devices appear to only support the ES2
58 // extension. As an extreme (optional) solution, we can fallback to using ES2 shading language
59 // if we want to prioritize external texture support. skbug.com/7713
60 if (GR_IS_GR_GL_ES(interface->fStandard) &&
61 options.fPreferExternalImagesOverES3 &&
62 !options.fDisableDriverCorrectnessWorkarounds &&
63 interface->hasExtension("GL_OES_EGL_image_external") &&
64 args.fGLSLGeneration >= SkSL::GLSLGeneration::k330 &&
65 !interface->hasExtension("GL_OES_EGL_image_external_essl3") &&
66 !interface->hasExtension("OES_EGL_image_external_essl3")) {
67 args.fGLSLGeneration = SkSL::GLSLGeneration::k100es;
68 }
69
70 args.fContextOptions = &options;
71 args.fInterface = std::move(interface);
72
73 return std::unique_ptr<GrGLContext>(new GrGLContext(std::move(args)));
74}
75
77
79 fInterface = std::move(args.fInterface);
80 fDriverInfo = args.fDriverInfo;
81 fGLSLGeneration = args.fGLSLGeneration;
82
83 fGLCaps = sk_make_sp<GrGLCaps>(*args.fContextOptions, *this, fInterface.get());
84}
const char * options
bool GrGLGetGLSLGeneration(const GrGLDriverInfo &info, SkSL::GLSLGeneration *generation)
Definition GrGLGLSL.cpp:12
#define GR_IS_GR_GL_ES(standard)
Definition GrGLTypes.h:49
GrGLDriverInfo GrGLGetDriverInfo(const GrGLInterface *interface)
Definition GrGLUtil.cpp:723
#define GR_GL_INVALID_VER
Definition GrGLUtil.h:37
GrGLDriverInfo fDriverInfo
Definition GrGLContext.h:92
GrGLContextInfo(GrGLContextInfo &&)=default
sk_sp< const GrGLInterface > fInterface
Definition GrGLContext.h:91
SkSL::GLSLGeneration fGLSLGeneration
Definition GrGLContext.h:93
sk_sp< GrGLCaps > fGLCaps
Definition GrGLContext.h:94
~GrGLContext() override
static std::unique_ptr< GrGLContext > Make(sk_sp< const GrGLInterface >, const GrContextOptions &)
T * get() const
Definition SkRefCnt.h:303
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args