1212#include " third_party/skia/include/core/SkSurface.h"
1313#include " third_party/skia/include/gpu/GrBackendSurface.h"
1414#include " third_party/skia/include/gpu/GrContextOptions.h"
15- #include " third_party/skia/include/gpu/gl/GrGLAssembleInterface.h"
16- #include " third_party/skia/include/gpu/gl/GrGLInterface.h"
1715
1816// These are common defines present on all OpenGL headers. However, we don't
1917// want to perform GL header reasolution on each platform we support. So just
2220#define GPU_GL_RGBA8 0x8058
2321#define GPU_GL_RGBA4 0x8056
2422#define GPU_GL_RGB565 0x8D62
25- #define GPU_GL_VERSION 0x1F02
2623
2724namespace shell {
2825
@@ -33,9 +30,6 @@ static const int kGrCacheMaxCount = 8192;
3330// cache.
3431static const size_t kGrCacheMaxByteSize = 512 * (1 << 20 );
3532
36- // Version string prefix that identifies an OpenGL ES implementation.
37- static const char kGLESVersionPrefix [] = " OpenGL ES" ;
38-
3933GPUSurfaceGL::GPUSurfaceGL (GPUSurfaceGLDelegate* delegate)
4034 : delegate_(delegate), weak_factory_(this ) {
4135 if (!delegate_->GLContextMakeCurrent ()) {
@@ -44,8 +38,6 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate)
4438 return ;
4539 }
4640
47- proc_resolver_ = delegate_->GetGLProcResolver ();
48-
4941 GrContextOptions options;
5042
5143 options.fPersistentCache = PersistentCache::GetCacheForProcess ();
@@ -60,26 +52,7 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate)
6052 // A similar work-around is also used in shell/common/io_manager.cc.
6153 options.fDisableGpuYUVConversion = true ;
6254
63- sk_sp<const GrGLInterface> interface;
64-
65- if (proc_resolver_ == nullptr ) {
66- interface = GrGLMakeNativeInterface ();
67- } else {
68- auto gl_get_proc = [](void * context,
69- const char gl_proc_name[]) -> GrGLFuncPtr {
70- return reinterpret_cast <GrGLFuncPtr>(
71- reinterpret_cast <GPUSurfaceGL*>(context)->proc_resolver_ (
72- gl_proc_name));
73- };
74-
75- if (IsProcResolverOpenGLES ()) {
76- interface = GrGLMakeAssembledGLESInterface (this , gl_get_proc);
77- } else {
78- interface = GrGLMakeAssembledGLInterface (this , gl_get_proc);
79- }
80- }
81-
82- auto context = GrContext::MakeGL (interface, options);
55+ auto context = GrContext::MakeGL (delegate_->GetGLInterface (), options);
8356
8457 if (context == nullptr ) {
8558 FML_LOG (ERROR) << " Failed to setup Skia Gr context." ;
@@ -105,8 +78,6 @@ GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrContext> gr_context,
10578 return ;
10679 }
10780
108- proc_resolver_ = delegate_->GetGLProcResolver ();
109-
11081 delegate_->GLContextClearCurrent ();
11182
11283 valid_ = true ;
@@ -133,20 +104,6 @@ GPUSurfaceGL::~GPUSurfaceGL() {
133104 delegate_->GLContextClearCurrent ();
134105}
135106
136- bool GPUSurfaceGL::IsProcResolverOpenGLES () {
137- using GLGetStringProc = const char * (*)(uint32_t );
138- GLGetStringProc gl_get_string =
139- reinterpret_cast <GLGetStringProc>(proc_resolver_ (" glGetString" ));
140- FML_CHECK (gl_get_string)
141- << " The GL proc resolver could not resolve glGetString" ;
142- const char * gl_version_string = gl_get_string (GPU_GL_VERSION);
143- FML_CHECK (gl_version_string)
144- << " The GL proc resolver's glGetString(GL_VERSION) failed" ;
145-
146- return strncmp (gl_version_string, kGLESVersionPrefix ,
147- strlen (kGLESVersionPrefix )) == 0 ;
148- }
149-
150107// |shell::Surface|
151108bool GPUSurfaceGL::IsValid () {
152109 return valid_;
@@ -372,27 +329,4 @@ bool GPUSurfaceGL::MakeRenderContextCurrent() {
372329 return delegate_->GLContextMakeCurrent ();
373330}
374331
375- bool GPUSurfaceGLDelegate::GLContextFBOResetAfterPresent () const {
376- return false ;
377- }
378-
379- bool GPUSurfaceGLDelegate::UseOffscreenSurface () const {
380- return false ;
381- }
382-
383- SkMatrix GPUSurfaceGLDelegate::GLContextSurfaceTransformation () const {
384- SkMatrix matrix;
385- matrix.setIdentity ();
386- return matrix;
387- }
388-
389- flow::ExternalViewEmbedder* GPUSurfaceGLDelegate::GetExternalViewEmbedder () {
390- return nullptr ;
391- }
392-
393- GPUSurfaceGLDelegate::GLProcResolver GPUSurfaceGLDelegate::GetGLProcResolver ()
394- const {
395- return nullptr ;
396- }
397-
398332} // namespace shell
0 commit comments