Chromium Code Reviews| Index: ui/gl/gl_image_io_surface.mm |
| diff --git a/ui/gl/gl_image_io_surface.mm b/ui/gl/gl_image_io_surface.mm |
| index e7b0dc96a8a235359087bb127b556103572e1336..d3c8e270b11a68115a30760ca8c3ab37d697c301 100644 |
| --- a/ui/gl/gl_image_io_surface.mm |
| +++ b/ui/gl/gl_image_io_surface.mm |
| @@ -18,6 +18,7 @@ |
| #include "ui/gl/gl_bindings.h" |
| #include "ui/gl/gl_context.h" |
| #include "ui/gl/gl_helper.h" |
| +#include "ui/gl/gl_implementation.h" |
| #include "ui/gl/scoped_api.h" |
| #include "ui/gl/scoped_binders.h" |
| #include "ui/gl/scoped_cgl.h" |
| @@ -32,10 +33,25 @@ using gfx::BufferFormat; |
| namespace gl { |
| namespace { |
| -const char kGLSLVersion[] = "#version 110"; |
| +const char kVertexHeaderCompatiblityProfile[] = "#version 110"; |
| -const char kTextureRectangleRequired[] = |
| - "#extension GL_ARB_texture_rectangle : require"; |
| +const char kVertexHeaderCoreProfile[] = |
| + "#version 150\n" |
| + "#define attribute in\n" |
| + "#define varying out\n"; |
|
Ken Russell (switch to Gerrit)
2016/04/14 00:01:15
I suggest naming these ATTRIBUTE and VARYING and r
ccameron
2016/04/14 00:25:13
Good point -- done.
|
| + |
| +const char kFragmentHeaderCompatiblityProfile[] = |
| + "#version 110\n" |
| + "#extension GL_ARB_texture_rectangle : require\n" |
| + "#define FRAGCOLOR gl_FragColor\n" |
| + "#define TEX texture2DRect\n"; |
| + |
| +const char kFragmentHeaderCoreProfile[] = |
| + "#version 150\n" |
| + "#define varying in\n" |
| + "#define TEX texture\n" |
| + "#define FRAGCOLOR frag_color\n" |
| + "out vec4 FRAGCOLOR;\n"; |
| // clang-format off |
| const char kVertexShader[] = |
| @@ -60,9 +76,9 @@ STRINGIZE( |
| vec3(0.0, -.391, 2.018), |
| vec3(1.596, -.813, 0.0)); |
| vec3 yuv = vec3( |
| - texture2DRect(a_y_texture, v_texCoord).r, |
| - texture2DRect(a_uv_texture, v_texCoord * 0.5).rg); |
| - gl_FragColor = vec4(yuv_matrix * (yuv + yuv_adj), 1.0); |
| + TEX(a_y_texture, v_texCoord).r, |
| + TEX(a_uv_texture, v_texCoord * 0.5).rg); |
| + FRAGCOLOR = vec4(yuv_matrix * (yuv + yuv_adj), 1.0); |
| } |
| ); |
| // clang-format on |
| @@ -235,17 +251,23 @@ GLImageIOSurface::RGBConverter::GetForCurrentContext() { |
| GLImageIOSurface::RGBConverter::RGBConverter(CGLContextObj cgl_context) |
| : cgl_context_(cgl_context, base::scoped_policy::RETAIN) { |
| + bool use_core_profile = |
| + gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGLCoreProfile; |
| gfx::ScopedSetGLToRealGLApi scoped_set_gl_api; |
| glGenFramebuffersEXT(1, &framebuffer_); |
| vertex_buffer_ = gfx::GLHelper::SetupQuadVertexBuffer(); |
| vertex_shader_ = gfx::GLHelper::LoadShader( |
| GL_VERTEX_SHADER, |
| - base::StringPrintf("%s\n%s", kGLSLVersion, kVertexShader).c_str()); |
| + base::StringPrintf("%s\n%s", |
| + use_core_profile ? kVertexHeaderCoreProfile |
| + : kVertexHeaderCompatiblityProfile, |
| + kVertexShader).c_str()); |
| fragment_shader_ = gfx::GLHelper::LoadShader( |
| GL_FRAGMENT_SHADER, |
| - base::StringPrintf("%s\n%s\n%s", kGLSLVersion, kTextureRectangleRequired, |
| - kFragmentShader) |
| - .c_str()); |
| + base::StringPrintf("%s\n%s", |
| + use_core_profile ? kFragmentHeaderCoreProfile |
| + : kFragmentHeaderCompatiblityProfile, |
| + kFragmentShader).c_str()); |
| program_ = gfx::GLHelper::SetupProgram(vertex_shader_, fragment_shader_); |
| gfx::ScopedUseProgram use_program(program_); |