diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-16 08:29:51 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-16 08:29:51 +0000 |
commit | 3de3805b5f580622ba884f0a3892b70a6e232654 (patch) | |
tree | c7302e923919e49b654fcb8f4c50fa115d58addc | |
parent | 26b2a65aaa4e9cc352f90a1a2ac5619edd8a2e54 (diff) | |
download | chromium_src-3de3805b5f580622ba884f0a3892b70a6e232654.zip chromium_src-3de3805b5f580622ba884f0a3892b70a6e232654.tar.gz chromium_src-3de3805b5f580622ba884f0a3892b70a6e232654.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290136 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/BUILD.gn | 1 | ||||
-rw-r--r-- | cc/cc.gyp | 1 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface_mac.mm | 3 | ||||
-rw-r--r-- | ui/gl/DEPS | 10 | ||||
-rw-r--r-- | ui/gl/gl.gyp | 1 | ||||
-rw-r--r-- | ui/gl/gl_context_glx.cc | 1 | ||||
-rw-r--r-- | ui/gl/gl_context_mac.mm | 1 | ||||
-rw-r--r-- | ui/gl/gl_surface_android.cc | 3 | ||||
-rw-r--r-- | ui/gl/gl_surface_egl.cc | 5 | ||||
-rw-r--r-- | ui/gl/gl_surface_glx.cc | 1 | ||||
-rw-r--r-- | ui/gl/gl_surface_mac.cc | 5 | ||||
-rw-r--r-- | ui/gl/gl_surface_osmesa.cc | 17 | ||||
-rw-r--r-- | ui/gl/gl_surface_osmesa.h | 4 | ||||
-rw-r--r-- | ui/gl/gl_surface_win.cc | 11 | ||||
-rw-r--r-- | ui/gl/gl_surface_x11.cc | 7 |
15 files changed, 39 insertions, 32 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index ddabbdd..c2f1cf4 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -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', diff --git a/content/common/gpu/image_transport_surface_mac.mm b/content/common/gpu/image_transport_surface_mac.mm index c193f6f..3a48063 100644 --- a/content/common/gpu/image_transport_surface_mac.mm +++ b/content/common/gpu/image_transport_surface_mac.mm @@ -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; @@ -1,8 +1,16 @@ 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", + ] +} diff --git a/ui/gl/gl.gyp b/ui/gl/gl.gyp index 229b21f..49c12f2 100644 --- a/ui/gl/gl.gyp +++ b/ui/gl/gl.gyp @@ -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': { diff --git a/ui/gl/gl_context_glx.cc b/ui/gl/gl_context_glx.cc index d5ab073..9b6cfb4 100644 --- a/ui/gl/gl_context_glx.cc +++ b/ui/gl/gl_context_glx.cc @@ -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" diff --git a/ui/gl/gl_context_mac.mm b/ui/gl/gl_context_mac.mm index 4b9c8dd..8cd58b1 100644 --- a/ui/gl/gl_context_mac.mm +++ b/ui/gl/gl_context_mac.mm @@ -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" diff --git a/ui/gl/gl_surface_android.cc b/ui/gl/gl_surface_android.cc index 1304b38..1254da2 100644 --- a/ui/gl/gl_surface_android.cc +++ b/ui/gl/gl_surface_android.cc @@ -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; diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc index e73ba4e..5a0538e 100644 --- a/ui/gl/gl_surface_egl.cc +++ b/ui/gl/gl_surface_egl.cc @@ -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" diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc index 58f97f5..05ab13b 100644 --- a/ui/gl/gl_surface_glx.cc +++ b/ui/gl/gl_surface_glx.cc @@ -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" diff --git a/ui/gl/gl_surface_mac.cc b/ui/gl/gl_surface_mac.cc index dd5fa0e..1852beb 100644 --- a/ui/gl/gl_surface_mac.cc +++ b/ui/gl/gl_surface_mac.cc @@ -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; diff --git a/ui/gl/gl_surface_osmesa.cc b/ui/gl/gl_surface_osmesa.cc index 58d955b..4c49166 100644 --- a/ui/gl/gl_surface_osmesa.cc +++ b/ui/gl/gl_surface_osmesa.cc @@ -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(); } diff --git a/ui/gl/gl_surface_osmesa.h b/ui/gl/gl_surface_osmesa.h index b4b4827..472d7b1 100644 --- a/ui/gl/gl_surface_osmesa.h +++ b/ui/gl/gl_surface_osmesa.h @@ -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; diff --git a/ui/gl/gl_surface_win.cc b/ui/gl/gl_surface_win.cc index c0a223b..0001103 100644 --- a/ui/gl/gl_surface_win.cc +++ b/ui/gl/gl_surface_win.cc @@ -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; diff --git a/ui/gl/gl_surface_x11.cc b/ui/gl/gl_surface_x11.cc index a5d5aab..bc9f1e6 100644 --- a/ui/gl/gl_surface_x11.cc +++ b/ui/gl/gl_surface_x11.cc @@ -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; |