<commit_before>// Copyright (c) 2010 The Chromium OS 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 "window_manager/compositor/gl/real_gl_interface.h"

#include <string>

#include "base/logging.h"
#include "window_manager/x11/real_x_connection.h"

using std::string;

namespace window_manager {

static string kGlxExtensions;
static string kGlExtensions;
static PFNGLXBINDTEXIMAGEEXTPROC _gl_bind_tex_image = NULL;
static PFNGLXRELEASETEXIMAGEEXTPROC _gl_release_tex_image = NULL;
static PFNGLXCREATEPIXMAPPROC _gl_create_pixmap = NULL;
static PFNGLXDESTROYPIXMAPPROC _gl_destroy_pixmap = NULL;
static PFNGLXCOPYSUBBUFFERMESAPROC _gl_copy_sub_buffer = NULL;

// True if GL supports the anisotropic sampling extension.
static bool supports_anisotropy = false;

// The maximum anisotropy sampling value.  The value 1.0 means no
// anisotropic sampling is performed.  See the following URL for more
// information:
// http://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt
static float max_anisotropy = 1.0f;

RealGLInterface::RealGLInterface(RealXConnection* connection)
    : xconn_(connection),
      has_texture_from_pixmap_extension_(false) {
  Display* display = xconn_->GetDisplay();
  if (kGlxExtensions.size() == 0) {
    kGlxExtensions = string(glXQueryExtensionsString(
        display, DefaultScreen(display)));
    LOG(INFO) << "Supported GLX extensions: " << kGlxExtensions;
  }
  if (kGlxExtensions.find("GLX_EXT_texture_from_pixmap") != string::npos) {
    if (_gl_bind_tex_image == NULL) {
      _gl_bind_tex_image = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXBindTexImageEXT")));
    }
    CHECK(_gl_bind_tex_image)
        << "Unable to find proc address for glXBindTexImageEXT";

    if (_gl_release_tex_image == NULL) {
      _gl_release_tex_image = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXReleaseTexImageEXT")));
    }
    CHECK(_gl_release_tex_image)
        << "Unable to find proc address for glXReleaseTexImageEXT";
    has_texture_from_pixmap_extension_ = true;
  }
  if (kGlxExtensions.find("GLX_SGIX_fbconfig") != string::npos) {
    if (_gl_create_pixmap == NULL) {
      _gl_create_pixmap = reinterpret_cast<PFNGLXCREATEPIXMAPPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXCreatePixmap")));
    }
    CHECK(_gl_create_pixmap)
        << "Unable to find proc address for glXCreatePixmap";

    if (_gl_destroy_pixmap == NULL) {
      _gl_destroy_pixmap = reinterpret_cast<PFNGLXDESTROYPIXMAPPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXDestroyPixmap")));
    }
    CHECK(_gl_destroy_pixmap)
        << "Unable to find proc address for glXDestroyPixmap";
  } else {
    CHECK(false) << "FBConfig not supported on this device.";
  }
  if (kGlxExtensions.find("GLX_MESA_copy_sub_buffer") != string::npos) {
    if (_gl_copy_sub_buffer == NULL) {
      _gl_copy_sub_buffer = reinterpret_cast<PFNGLXCOPYSUBBUFFERMESAPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXCopySubBufferMESA")));
    }
    if (_gl_copy_sub_buffer == NULL) {
      LOG(INFO) << "glXCopySubBufferMESA is un-available: "
                << "unable to find proc address.";
    } else {
      LOG(INFO) << "glXCopySubBufferMESA is available.";
    }
  } else {
      LOG(INFO) << "glXCopySubBufferMESA is un-available: "
                << "not supported on this device.";
  }
  GLint attributes[] = {
    GLX_RGBA,
    GLX_DOUBLEBUFFER,
    GLX_RED_SIZE, 8,
    GLX_GREEN_SIZE, 8,
    GLX_BLUE_SIZE, 8,<commit_msg>Remove detection of the GLX_SGIX_fbconfig extension, this is not what we need to detect availability of the glx create/destroy pixmap hooks. Instead, make it conditional on texture_from_pixmap.<commit_after>// Copyright (c) 2010 The Chromium OS 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 "window_manager/compositor/gl/real_gl_interface.h"

#include <string>

#include "base/logging.h"
#include "window_manager/x11/real_x_connection.h"

using std::string;

namespace window_manager {

static string kGlxExtensions;
static string kGlExtensions;
static PFNGLXBINDTEXIMAGEEXTPROC _gl_bind_tex_image = NULL;
static PFNGLXRELEASETEXIMAGEEXTPROC _gl_release_tex_image = NULL;
static PFNGLXCREATEPIXMAPPROC _gl_create_pixmap = NULL;
static PFNGLXDESTROYPIXMAPPROC _gl_destroy_pixmap = NULL;
static PFNGLXCOPYSUBBUFFERMESAPROC _gl_copy_sub_buffer = NULL;

// True if GL supports the anisotropic sampling extension.
static bool supports_anisotropy = false;

// The maximum anisotropy sampling value.  The value 1.0 means no
// anisotropic sampling is performed.  See the following URL for more
// information:
// http://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt
static float max_anisotropy = 1.0f;

RealGLInterface::RealGLInterface(RealXConnection* connection)
    : xconn_(connection),
      has_texture_from_pixmap_extension_(false) {
  Display* display = xconn_->GetDisplay();
  if (kGlxExtensions.size() == 0) {
    kGlxExtensions = string(glXQueryExtensionsString(
        display, DefaultScreen(display)));
    LOG(INFO) << "Supported GLX extensions: " << kGlxExtensions;
  }
  if (kGlxExtensions.find("GLX_EXT_texture_from_pixmap") != string::npos) {
    if (_gl_bind_tex_image == NULL) {
      _gl_bind_tex_image = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXBindTexImageEXT")));
    }
    CHECK(_gl_bind_tex_image)
        << "Unable to find proc address for glXBindTexImageEXT";

    if (_gl_release_tex_image == NULL) {
      _gl_release_tex_image = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXReleaseTexImageEXT")));
    }
    CHECK(_gl_release_tex_image)
        << "Unable to find proc address for glXReleaseTexImageEXT";

    // Here we assume that GLX 1.3 is present (since it is a dependency of
    // GLX_EXT_texture_from_pixmap it should be there).
    if (_gl_create_pixmap == NULL) {
      _gl_create_pixmap = reinterpret_cast<PFNGLXCREATEPIXMAPPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXCreatePixmap")));
    }
    CHECK(_gl_create_pixmap)
        << "Unable to find proc address for glXCreatePixmap";

    if (_gl_destroy_pixmap == NULL) {
      _gl_destroy_pixmap = reinterpret_cast<PFNGLXDESTROYPIXMAPPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXDestroyPixmap")));
    }
    CHECK(_gl_destroy_pixmap)
        << "Unable to find proc address for glXDestroyPixmap";

    has_texture_from_pixmap_extension_ = true;
  }
  if (kGlxExtensions.find("GLX_MESA_copy_sub_buffer") != string::npos) {
    if (_gl_copy_sub_buffer == NULL) {
      _gl_copy_sub_buffer = reinterpret_cast<PFNGLXCOPYSUBBUFFERMESAPROC>(
          glXGetProcAddress(
              reinterpret_cast<const GLubyte*>("glXCopySubBufferMESA")));
    }
    if (_gl_copy_sub_buffer == NULL) {
      LOG(INFO) << "glXCopySubBufferMESA is un-available: "
                << "unable to find proc address.";
    } else {
      LOG(INFO) << "glXCopySubBufferMESA is available.";
    }
  } else {
      LOG(INFO) << "glXCopySubBufferMESA is un-available: "
                << "not supported on this device.";
  }
  GLint attributes[] = {
    GLX_RGBA,
    GLX_DOUBLEBUFFER,
    GLX_RED_SIZE, 8,
    GLX_GREEN_SIZE, 8,
    GLX_BLUE_SIZE, 8,
{'fraction_non_alphanumeric': 0.09394250513347023, 'fraction_numerical': 0.0038501026694045173, 'mean_word_length': 3.9074307304785894, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1537635', 'n_tokens_mistral': 2622, 'n_tokens_neox': 2570, 'n_words': 539}