flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.72k stars 27.62k forks source link

[Impeller] OpenGLES Proc Table should use `std::string_view` not `char*` #135922

Open matanlurey opened 1 year ago

matanlurey commented 1 year ago

... to make ownership semantics more clear and not rely on raw pointers where we don't need to.

See below:

const char* GLErrorToString(GLenum value);
bool GLErrorIsFatal(GLenum value);

struct AutoErrorCheck {
  const PFNGLGETERRORPROC error_fn;
  const char* name;

  AutoErrorCheck(PFNGLGETERRORPROC error, const char* name)
      : error_fn(error), name(name) {}

  ~AutoErrorCheck() {
    if (error_fn) {
      auto error = error_fn();
      if (error == GL_NO_ERROR) {
        return;
      }
      if (GLErrorIsFatal(error)) {
        FML_LOG(FATAL) << "Fatal GL Error " << GLErrorToString(error) << "("
                       << error << ")"
                       << " encountered on call to " << name;
      } else {
        FML_LOG(ERROR) << "GL Error " << GLErrorToString(error) << "(" << error
                       << ")"
                       << " encountered on call to " << name;
      }
    }
  }
};

template <class T>
struct GLProc {
  using GLFunctionType = T;

  //----------------------------------------------------------------------------
  /// The name of the GL function.
  ///
  const char* name = nullptr;
ALLENGJOSE commented 1 year ago

Can I work on this issue?

matanlurey commented 1 year ago

Can I work on this issue?

Sure, feel free to send a PR.