From 53b2940c6d89a629775ebf92e468af9ee9005eb1 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Thu, 23 Feb 2017 16:02:53 -0800 Subject: [PATCH] Remove rarely used GLConnection stuff in flow. (flutter/engine#3440) I had added this initially as a means of making it easier to deal with OpenGL directly in Flow. However, we are moving away from dealing with the client rendering APIs directly. Instead, delegating everything to Skia. Besides, we only ever used this to log the GPU description in case of context setup failures. This has not proved to be useful so far. Also, having this in place is making it difficult to remove all dependencies on GL in Shell. --- engine/src/flutter/flow/BUILD.gn | 6 - engine/src/flutter/flow/gl_connection.cc | 183 ------------------ engine/src/flutter/flow/gl_connection.h | 80 -------- engine/src/flutter/flow/open_gl.h | 32 --- .../src/flutter/shell/gpu/gpu_surface_gl.cc | 5 +- 5 files changed, 1 insertion(+), 305 deletions(-) delete mode 100644 engine/src/flutter/flow/gl_connection.cc delete mode 100644 engine/src/flutter/flow/gl_connection.h delete mode 100644 engine/src/flutter/flow/open_gl.h diff --git a/engine/src/flutter/flow/BUILD.gn b/engine/src/flutter/flow/BUILD.gn index e0961b8562..28bed0ef16 100644 --- a/engine/src/flutter/flow/BUILD.gn +++ b/engine/src/flutter/flow/BUILD.gn @@ -61,11 +61,5 @@ source_set("flow") { "//apps/mozart/lib/skia", "//apps/mozart/services/composition", ] - } else { - sources += [ - "gl_connection.cc", - "gl_connection.h", - "open_gl.h", - ] } } diff --git a/engine/src/flutter/flow/gl_connection.cc b/engine/src/flutter/flow/gl_connection.cc deleted file mode 100644 index c26be4b0e7..0000000000 --- a/engine/src/flutter/flow/gl_connection.cc +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "gl_connection.h" - -#include -#include -#include -#include - -namespace flow { - -static std::string GLGetString(GLenum name) { - auto string = reinterpret_cast(glGetString(name)); - return string != nullptr ? string : ""; -} - -static GLConnection::Version GLGetVersion(GLenum name) { - GLConnection::Version version; - - auto versionString = GLGetString(name); - - if (versionString.length() == 0) { - return version; - } - - { - // Check for the GLSL ES prefix. - const std::string glslesPrefix("OpenGL ES GLSL ES "); - if (versionString.compare(0, glslesPrefix.length(), glslesPrefix) == 0) { - version.isES = true; - versionString = versionString.substr(glslesPrefix.length()); - } - } - - { - // Check for the GL ES prefix. - const std::string glesPrefix("OpenGL ES "); - if (versionString.compare(0, glesPrefix.length(), glesPrefix) == 0) { - version.isES = true; - versionString = versionString.substr(glesPrefix.length()); - } - } - - std::istringstream stream(versionString); - - for (size_t i = 0; i < 3; i++) { - size_t item = 0; - if (stream >> item) { - version.items[i] = item; - - if (stream.peek() == ' ') { - stream.ignore(1); // space - stream >> version.vendorString; - break; - } else { - stream.ignore(1); // dot - } - } else { - break; - } - } - - return version; -} - -static std::string VersionToString(GLConnection::Version version) { - if (version.major == 0 && version.minor == 0 && version.release == 0) { - return "Unknown"; - } - - std::stringstream stream; - - stream << version.major << "." << version.minor; - - if (version.release != 0) { - stream << "." << version.release; - } - - if (version.vendorString.size() != 0) { - stream << " " << version.vendorString; - } - - if (version.isES) { - stream << " ES"; - } - - return stream.str(); -} - -GLConnection::GLConnection() - : vendor_(GLGetString(GL_VENDOR)), - renderer_(GLGetString(GL_RENDERER)), - version_(GLGetVersion(GL_VERSION)), - shading_language_version_(GLGetVersion(GL_SHADING_LANGUAGE_VERSION)) { - std::istringstream extensionsStream(GLGetString(GL_EXTENSIONS)); - extensionsStream >> std::skipws; - std::string extension; - while (extensionsStream >> extension) { - extensions_.emplace(std::move(extension)); - } -} - -GLConnection::~GLConnection() = default; - -const std::string& GLConnection::Vendor() const { - return vendor_; -} - -const std::string& GLConnection::Renderer() const { - return renderer_; -} - -const GLConnection::Version& GLConnection::GLVersion() const { - return version_; -} - -std::string GLConnection::VersionString() const { - return VersionToString(version_); -} - -const GLConnection::Version& GLConnection::ShadingLanguageVersion() const { - return shading_language_version_; -} - -std::string GLConnection::ShadingLanguageVersionString() const { - return VersionToString(shading_language_version_); -} - -std::string GLConnection::Platform() const { - std::stringstream stream; - stream << Vendor() << ": " << Renderer(); - return stream.str(); -} - -const std::set& GLConnection::Extensions() const { - return extensions_; -} - -std::string GLConnection::Description() const { - std::vector> items; - - items.emplace_back("Vendor", Vendor()); - items.emplace_back("Renderer", Renderer()); - items.emplace_back("Version", VersionString()); - items.emplace_back("Shader Version", ShadingLanguageVersionString()); - - std::string extensionsLabel("Extensions"); - - size_t padding = extensionsLabel.size(); - - for (const auto& item : items) { - padding = std::max(padding, item.first.size()); - } - - padding += 1; - - std::stringstream stream; - - stream << std::endl; - - for (const auto& item : items) { - stream << std::setw(padding) << item.first << std::setw(0) << ": " - << item.second << std::endl; - } - - if (extensions_.size() != 0) { - std::string paddingString; - paddingString.resize(padding + 2, ' '); - - stream << std::setw(padding) << extensionsLabel << std::setw(0) << ": " - << extensions_.size() << " Available" << std::endl; - - for (const auto& extension : extensions_) { - stream << paddingString << extension << std::endl; - } - } - - return stream.str(); -} - -} // namespace flow diff --git a/engine/src/flutter/flow/gl_connection.h b/engine/src/flutter/flow/gl_connection.h deleted file mode 100644 index 16b68f6bbf..0000000000 --- a/engine/src/flutter/flow/gl_connection.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLOW_GL_CONNECTION_H_ -#define FLOW_GL_CONNECTION_H_ - -#include "lib/ftl/macros.h" -#include "open_gl.h" - -#include -#include - -#ifdef major -#undef major -#endif - -#ifdef minor -#undef minor -#endif - -namespace flow { - -class GLConnection { - public: - struct Version { - union { - struct { - size_t major; - size_t minor; - size_t release; - }; - size_t items[3]; - }; - - std::string vendorString; - - bool isES; - - Version() : major(0), minor(0), release(0), isES(false) {} - - Version(size_t theMajor, size_t theMinor, size_t theRelease) - : major(theMajor), minor(theMinor), release(theRelease), isES(false) {} - }; - - GLConnection(); - - ~GLConnection(); - - const std::string& Vendor() const; - - const std::string& Renderer() const; - - std::string Platform() const; - - const Version& GLVersion() const; - - std::string VersionString() const; - - const Version& ShadingLanguageVersion() const; - - std::string ShadingLanguageVersionString() const; - - const std::set& Extensions() const; - - std::string Description() const; - - private: - std::string vendor_; - std::string renderer_; - Version version_; - Version shading_language_version_; - std::set extensions_; - - FTL_DISALLOW_COPY_AND_ASSIGN(GLConnection); -}; - -} // namespace flow - -#endif // FLOW_GL_CONNECTION_H_ \ No newline at end of file diff --git a/engine/src/flutter/flow/open_gl.h b/engine/src/flutter/flow/open_gl.h deleted file mode 100644 index 9058355d8a..0000000000 --- a/engine/src/flutter/flow/open_gl.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_FLOW_OPEN_GL_H_ -#define FLUTTER_FLOW_OPEN_GL_H_ - -#include "lib/ftl/build_config.h" - -#if defined(OS_IOS) - -#include - -#elif defined(OS_MACOSX) - -#include - -#elif defined(OS_ANDROID) || defined(OS_FUCHSIA) - -#include - -#elif defined(OS_LINUX) - -#include - -#else - -#error OpenGL headers not found for this platform. - -#endif - -#endif // FLUTTER_FLOW_OPEN_GL_H_ diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc index 81624f6a5c..247447beb2 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc @@ -4,7 +4,6 @@ #include "gpu_surface_gl.h" -#include "flutter/flow/gl_connection.h" #include "flutter/glue/trace_event.h" #include "lib/ftl/arraysize.h" #include "lib/ftl/logging.h" @@ -50,9 +49,7 @@ bool GPUSurfaceGL::Setup() { sk_sp(GrContext::Create(kOpenGL_GrBackend, backend_context)); if (context_ == nullptr) { - flow::GLConnection connection; - FTL_LOG(INFO) << "Failed to setup GL context. Aborting."; - FTL_LOG(INFO) << connection.Description(); + FTL_LOG(INFO) << "Failed to setup Skia Gr context."; return false; }