| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 5 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 8 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 9 | 9 |
| 10 using gpu::gles2::GLES2Interface; | 10 using gpu::gles2::GLES2Interface; |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 template <typename R, typename... Args> | 13 template <typename R, typename... Args> |
| 14 std::function<R(Args...)> gles_bind(R (GLES2Interface::*func)(Args...), | 14 std::function<R(Args...)> gles_bind(R (GLES2Interface::*func)(Args...), |
| 15 GLES2Interface* gles2Interface) { | 15 GLES2Interface* gles2Interface) { |
| 16 return [func, gles2Interface](Args... args) { | 16 return [func, gles2Interface](Args... args) { |
| 17 return (gles2Interface->*func)(args...); | 17 return (gles2Interface->*func)(args...); |
| 18 }; | 18 }; |
| 19 } | 19 } |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 namespace skia_bindings { | 22 namespace skia_bindings { |
| 23 | 23 |
| 24 sk_sp<GrGLInterface> CreateGLES2InterfaceBindings(GLES2Interface* impl) { | 24 sk_sp<GrGLInterface> CreateGLES2InterfaceBindings(GLES2Interface* impl) { |
| 25 sk_sp<GrGLInterface> interface(new GrGLInterface); | 25 sk_sp<GrGLInterface> interface(new GrGLInterface); |
| 26 interface->fStandard = kGLES_GrGLStandard; | 26 interface->fStandard = kGLES_GrGLStandard; |
| 27 | 27 |
| 28 auto get_string = gles_bind(&GLES2Interface::GetString, impl); | 28 // Allowing Skia to use GL ES 3.0 caused a perf test regression (see Issue |
| 29 // 719572). Until that can be understood we are limiting to ES 2.0 (with |
| 30 // extensions). |
| 31 auto get_string = [impl](GLenum name) { |
| 32 if (name == GL_VERSION) |
| 33 return reinterpret_cast<const GLubyte*>("OpenGL ES 2.0 Chromium"); |
| 34 return impl->GetString(name); |
| 35 }; |
| 29 auto get_stringi = gles_bind(&GLES2Interface::GetStringi, impl); | 36 auto get_stringi = gles_bind(&GLES2Interface::GetStringi, impl); |
| 30 auto get_integerv = gles_bind(&GLES2Interface::GetIntegerv, impl); | 37 auto get_integerv = gles_bind(&GLES2Interface::GetIntegerv, impl); |
| 31 interface->fExtensions.init(kGLES_GrGLStandard, get_string, get_stringi, | 38 interface->fExtensions.init(kGLES_GrGLStandard, get_string, get_stringi, |
| 32 get_integerv); | 39 get_integerv); |
| 33 | 40 |
| 34 GrGLInterface::Functions* functions = &interface->fFunctions; | 41 GrGLInterface::Functions* functions = &interface->fFunctions; |
| 35 functions->fActiveTexture = gles_bind(&GLES2Interface::ActiveTexture, impl); | 42 functions->fActiveTexture = gles_bind(&GLES2Interface::ActiveTexture, impl); |
| 36 functions->fAttachShader = gles_bind(&GLES2Interface::AttachShader, impl); | 43 functions->fAttachShader = gles_bind(&GLES2Interface::AttachShader, impl); |
| 37 functions->fBindAttribLocation = | 44 functions->fBindAttribLocation = |
| 38 gles_bind(&GLES2Interface::BindAttribLocation, impl); | 45 gles_bind(&GLES2Interface::BindAttribLocation, impl); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 functions->fProgramPathFragmentInputGen = | 288 functions->fProgramPathFragmentInputGen = |
| 282 gles_bind(&GLES2Interface::ProgramPathFragmentInputGenCHROMIUM, impl); | 289 gles_bind(&GLES2Interface::ProgramPathFragmentInputGenCHROMIUM, impl); |
| 283 functions->fBindFragmentInputLocation = | 290 functions->fBindFragmentInputLocation = |
| 284 gles_bind(&GLES2Interface::BindFragmentInputLocationCHROMIUM, impl); | 291 gles_bind(&GLES2Interface::BindFragmentInputLocationCHROMIUM, impl); |
| 285 functions->fCoverageModulation = | 292 functions->fCoverageModulation = |
| 286 gles_bind(&GLES2Interface::CoverageModulationCHROMIUM, impl); | 293 gles_bind(&GLES2Interface::CoverageModulationCHROMIUM, impl); |
| 287 return interface; | 294 return interface; |
| 288 } | 295 } |
| 289 | 296 |
| 290 } // namespace skia_bindings | 297 } // namespace skia_bindings |
| OLD | NEW |