Commit 4da882a5 authored by jamesr@chromium.org's avatar jamesr@chromium.org

Restrict usage of mesa headers to targets that really need them

Many targets were getting mesa headers on their include paths even
though they never used them. This limits use of osmesa.h to the only
target that actually needs to interface directly with osmesa and
restricts use of the third_party/mesa/ headers to targets that need to
use the desktop GL bindings.

R=piman@chromium.org

Review URL: https://codereview.chromium.org/476403002

Cr-Commit-Position: refs/heads/master@{#290136}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290136 0039d316-1c4b-4281-b951-d872f2087c98
parent c27fd054
......@@ -474,7 +474,6 @@ component("cc") {
"//ui/events:events_base",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl",
]
forward_dependent_configs_from = [
"//skia",
......
......@@ -20,7 +20,6 @@
'<(DEPTH)/ui/events/events.gyp:events_base',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
'<(DEPTH)/ui/gl/gl.gyp:gl',
],
'variables': {
'optimize': 'max',
......
......@@ -18,7 +18,8 @@ namespace {
class DRTSurfaceOSMesa : public gfx::GLSurfaceOSMesa {
public:
// Size doesn't matter, the surface is resized to the right size later.
DRTSurfaceOSMesa() : GLSurfaceOSMesa(GL_RGBA, gfx::Size(1, 1)) {}
DRTSurfaceOSMesa()
: GLSurfaceOSMesa(gfx::OSMesaSurfaceFormatRGBA, gfx::Size(1, 1)) {}
// Implement a subset of GLSurface.
virtual bool SwapBuffers() OVERRIDE;
......
include_rules = [
"+third_party/khronos",
"+third_party/mesa/src/include",
"+third_party/skia",
"+ui/events",
"+ui/gfx",
"+ui/ozone/public",
]
specific_include_rules = {
# This is the only target that should use the osmesa.h header. Everything else
# should use the GLES2 headers from third_party/khronos/ or use gl_bindings.h to
# get access to desktop OpenGL.
"gl_surface_osmesa.cc": [
"+third_party/mesa/src/include/GL/osmesa.h",
]
}
......@@ -30,7 +30,6 @@
'include_dirs': [
'<(DEPTH)/third_party/swiftshader/include',
'<(DEPTH)/third_party/khronos',
'<(DEPTH)/third_party/mesa/src/include',
'<(gl_binding_output_dir)',
],
'direct_dependent_settings': {
......
......@@ -11,7 +11,6 @@ extern "C" {
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gl/GL/glextchromium.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
......
......@@ -6,7 +6,6 @@
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gl/gl_context_cgl.h"
#include "ui/gl/gl_context_osmesa.h"
#include "ui/gl/gl_context_stub.h"
......
......@@ -58,7 +58,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
CHECK_NE(kGLImplementationNone, GetGLImplementation());
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size));
scoped_refptr<GLSurface> surface(
new GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, size));
if (!surface->Initialize())
return NULL;
......
......@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This include must be here so that the includes provided transitively
// by gl_surface_egl.h don't make it impossible to compile this code.
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gl/gl_surface_egl.h"
#if defined(OS_ANDROID)
......@@ -21,7 +17,6 @@
#include "ui/gl/egl_util.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_osmesa.h"
#include "ui/gl/gl_surface_stub.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/scoped_make_current.h"
......
......@@ -20,7 +20,6 @@ extern "C" {
#include "base/threading/non_thread_safe.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/x11_connection.h"
#include "ui/gfx/x/x11_types.h"
......
......@@ -11,7 +11,6 @@
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
......@@ -130,8 +129,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
size));
scoped_refptr<GLSurface> surface(
new GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, size));
if (!surface->Initialize())
return NULL;
......
......@@ -11,9 +11,17 @@
namespace gfx {
GLSurfaceOSMesa::GLSurfaceOSMesa(unsigned format, const gfx::Size& size)
: format_(format),
size_(size) {
GLSurfaceOSMesa::GLSurfaceOSMesa(OSMesaSurfaceFormat format,
const gfx::Size& size)
: size_(size) {
switch (format) {
case OSMesaSurfaceFormatBGRA:
format_ = OSMESA_BGRA;
break;
case OSMesaSurfaceFormatRGBA:
format_ = OSMESA_RGBA;
break;
}
// Implementations of OSMesa surface do not support having a 0 size. In such
// cases use a (1, 1) surface.
if (size_.GetArea() == 0)
......@@ -92,7 +100,8 @@ bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; }
bool GLSurfaceOSMesaHeadless::SwapBuffers() { return true; }
GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless()
: GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)) {}
: GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)) {
}
GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); }
......
......@@ -11,12 +11,14 @@
namespace gfx {
enum OSMesaSurfaceFormat { OSMesaSurfaceFormatBGRA, OSMesaSurfaceFormatRGBA };
// A surface that the Mesa software renderer draws to. This is actually just a
// buffer in system memory. GetHandle returns a pointer to the buffer. These
// surfaces can be resized and resizing preserves the contents.
class GL_EXPORT GLSurfaceOSMesa : public GLSurface {
public:
GLSurfaceOSMesa(unsigned format, const gfx::Size& size);
GLSurfaceOSMesa(OSMesaSurfaceFormat format, const gfx::Size& size);
// Implement GLSurface.
virtual bool Initialize() OVERRIDE;
......
......@@ -11,7 +11,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/win/windows_version.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gfx/frame_time.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gl/gl_bindings.h"
......@@ -112,9 +111,9 @@ bool GLSurface::InitializeOneOffInternal() {
NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
gfx::AcceleratedWidget window)
: GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)),
window_(window),
device_context_(NULL) {
: GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, gfx::Size(1, 1)),
window_(window),
device_context_(NULL) {
DCHECK(window);
}
......@@ -265,8 +264,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
size));
scoped_refptr<GLSurface> surface(
new GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, size));
if (!surface->Initialize())
return NULL;
......
......@@ -8,7 +8,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
......@@ -79,7 +78,7 @@ bool GLSurface::InitializeOneOffInternal() {
NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
gfx::AcceleratedWidget window)
: GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)),
: GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)),
xdisplay_(gfx::GetXDisplay()),
window_graphics_context_(0),
window_(window),
......@@ -312,8 +311,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
size));
scoped_refptr<GLSurface> surface(
new GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, size));
if (!surface->Initialize())
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment