diff options
author | hendrikw <hendrikw@chromium.org> | 2015-09-01 21:28:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-02 04:28:57 +0000 |
commit | efa3a446183fbbff2034a03989f12543d0713e39 (patch) | |
tree | 6b3be72b8b68d39d047e76866ffbce201094fb0b | |
parent | 1ddd143afa3eacf010f32d7db0109cdb77ef608e (diff) | |
download | chromium_src-efa3a446183fbbff2034a03989f12543d0713e39.zip chromium_src-efa3a446183fbbff2034a03989f12543d0713e39.tar.gz chromium_src-efa3a446183fbbff2034a03989f12543d0713e39.tar.bz2 |
Add command_buffer_gles2
This is a very simple library that exposes some egl-like functions that
can be used by skia to use the command buffer as a backend for their
tests
Committed: https://crrev.com/604b615373e4e9f873db37cef9c6416176fc35f3
Cr-Commit-Position: refs/heads/master@{#346251}
Review URL: https://codereview.chromium.org/1220883008
Cr-Commit-Position: refs/heads/master@{#346840}
-rw-r--r-- | gpu/BUILD.gn | 31 | ||||
-rw-r--r-- | gpu/gles2_conform_support/egl/display.cc | 5 | ||||
-rw-r--r-- | gpu/gles2_conform_support/egl/display.h | 5 | ||||
-rw-r--r-- | gpu/gles2_conform_support/egl/egl.cc | 178 | ||||
-rw-r--r-- | gpu/gpu.gyp | 37 |
5 files changed, 170 insertions, 86 deletions
diff --git a/gpu/BUILD.gn b/gpu/BUILD.gn index 2668617..c5e8bd7 100644 --- a/gpu/BUILD.gn +++ b/gpu/BUILD.gn @@ -49,6 +49,37 @@ component("gpu") { ] } +# GYP version: //gpu/gpu.gyp:command_buffer_gles2 +shared_library("command_buffer_gles2") { + sources = [ + # TODO(hendrikw): Move egl out of gles2_conform_support. + "gles2_conform_support/egl/config.cc", + "gles2_conform_support/egl/config.h", + "gles2_conform_support/egl/display.cc", + "gles2_conform_support/egl/display.h", + "gles2_conform_support/egl/egl.cc", + "gles2_conform_support/egl/surface.cc", + "gles2_conform_support/egl/surface.h", + ] + + deps = [ + "//base", + "//gpu/command_buffer/client:client_sources", + "//gpu/command_buffer/client:gles2_c_lib", + "//gpu/command_buffer/client:gles2_cmd_helper_sources", + "//gpu/command_buffer/client:gles2_implementation", + "//gpu/command_buffer/service", + "//ui/gl:gl", + ] + + defines = [ "EGLAPIENTRY=" ] + if (current_os == "win") { + defines += [ "EGLAPI=__declspec(dllexport)" ] + } else { + defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ] + } +} + source_set("test_support") { testonly = true sources = [ diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc index 18f4742..2528cdc 100644 --- a/gpu/gles2_conform_support/egl/display.cc +++ b/gpu/gles2_conform_support/egl/display.cc @@ -5,6 +5,7 @@ #include "gpu/gles2_conform_support/egl/display.h" #include <vector> +#include "base/at_exit.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "gpu/command_buffer/client/gles2_implementation.h" @@ -31,8 +32,8 @@ Display::Display(EGLNativeDisplayType display_id) is_initialized_(false), create_offscreen_(false), create_offscreen_width_(0), - create_offscreen_height_(0) { -} + create_offscreen_height_(0), + exit_manager_(new base::AtExitManager) {} Display::~Display() { gles2::Terminate(); diff --git a/gpu/gles2_conform_support/egl/display.h b/gpu/gles2_conform_support/egl/display.h index adf3949..2202a96 100644 --- a/gpu/gles2_conform_support/egl/display.h +++ b/gpu/gles2_conform_support/egl/display.h @@ -30,6 +30,10 @@ class GLES2Implementation; } // namespace gles2 } // namespace gpu +namespace base { +class AtExitManager; +} // namespace base + namespace egl { class Config; @@ -104,6 +108,7 @@ class Display : private gpu::GpuControl { int create_offscreen_height_; scoped_refptr<gpu::TransferBufferManagerInterface> transfer_buffer_manager_; + scoped_ptr<base::AtExitManager> exit_manager_; scoped_ptr<gpu::CommandBufferService> command_buffer_; scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; diff --git a/gpu/gles2_conform_support/egl/egl.cc b/gpu/gles2_conform_support/egl/egl.cc index 343937f..e64285a 100644 --- a/gpu/gles2_conform_support/egl/egl.cc +++ b/gpu/gles2_conform_support/egl/egl.cc @@ -85,16 +85,18 @@ EGLint ValidateDisplayContext(EGLDisplay dpy, EGLContext context) { } // namespace extern "C" { -EGLint eglGetError() { +EGLAPI EGLint EGLAPIENTRY eglGetError() { // TODO(alokp): Fix me. return EGL_SUCCESS; } -EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) { +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { return new egl::Display(display_id); } -EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, + EGLint* major, + EGLint* minor) { if (dpy == EGL_NO_DISPLAY) return EglError(EGL_BAD_DISPLAY, EGL_FALSE); @@ -102,19 +104,21 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { if (!display->Initialize()) return EglError(EGL_NOT_INITIALIZED, EGL_FALSE); - int argc = 1; - const char* const argv[] = { - "dummy" - }; - base::CommandLine::Init(argc, argv); - gfx::GLSurface::InitializeOneOff(); + // eglInitialize can be called multiple times, prevent InitializeOneOff from + // being called multiple times. + if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) { + int argc = 1; + const char* const argv[] = {"dummy"}; + base::CommandLine::Init(argc, argv); + gfx::GLSurface::InitializeOneOff(); + } *major = 1; *minor = 4; return EglSuccess(EGL_TRUE); } -EGLBoolean eglTerminate(EGLDisplay dpy) { +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { EGLint error_code = ValidateDisplay(dpy); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -125,7 +129,7 @@ EGLBoolean eglTerminate(EGLDisplay dpy) { return EglSuccess(EGL_TRUE); } -const char* eglQueryString(EGLDisplay dpy, EGLint name) { +EGLAPI const char* EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) { EGLint error_code = ValidateDisplay(dpy); if (error_code != EGL_SUCCESS) return EglError(error_code, static_cast<const char*>(NULL)); @@ -144,11 +148,11 @@ const char* eglQueryString(EGLDisplay dpy, EGLint name) { } } -EGLBoolean eglChooseConfig(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, + const EGLint* attrib_list, + EGLConfig* configs, + EGLint config_size, + EGLint* num_config) { EGLint error_code = ValidateDisplay(dpy); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -163,10 +167,10 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, return EglSuccess(EGL_TRUE); } -EGLBoolean eglGetConfigs(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, + EGLConfig* configs, + EGLint config_size, + EGLint* num_config) { EGLint error_code = ValidateDisplay(dpy); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -181,10 +185,10 @@ EGLBoolean eglGetConfigs(EGLDisplay dpy, return EglSuccess(EGL_TRUE); } -EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) { +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, + EGLConfig config, + EGLint attribute, + EGLint* value) { EGLint error_code = ValidateDisplayConfig(dpy, config); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -196,10 +200,11 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, return EglSuccess(EGL_TRUE); } -EGLSurface eglCreateWindowSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) { +EGLAPI EGLSurface EGLAPIENTRY +eglCreateWindowSurface(EGLDisplay dpy, + EGLConfig config, + EGLNativeWindowType win, + const EGLint* attrib_list) { EGLint error_code = ValidateDisplayConfig(dpy, config); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_NO_SURFACE); @@ -215,9 +220,10 @@ EGLSurface eglCreateWindowSurface(EGLDisplay dpy, return EglSuccess(surface); } -EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) { +EGLAPI EGLSurface EGLAPIENTRY +eglCreatePbufferSurface(EGLDisplay dpy, + EGLConfig config, + const EGLint* attrib_list) { EGLint error_code = ValidateDisplayConfig(dpy, config); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_NO_SURFACE); @@ -246,15 +252,16 @@ EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, return EglSuccess(surface); } -EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) { +EGLAPI EGLSurface EGLAPIENTRY +eglCreatePixmapSurface(EGLDisplay dpy, + EGLConfig config, + EGLNativePixmapType pixmap, + const EGLint* attrib_list) { return EGL_NO_SURFACE; } -EGLBoolean eglDestroySurface(EGLDisplay dpy, - EGLSurface surface) { +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, + EGLSurface surface) { EGLint error_code = ValidateDisplaySurface(dpy, surface); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -264,64 +271,65 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, return EglSuccess(EGL_TRUE); } -EGLBoolean eglQuerySurface(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) { +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, + EGLSurface surface, + EGLint attribute, + EGLint* value) { return EGL_FALSE; } -EGLBoolean eglBindAPI(EGLenum api) { +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) { return EGL_FALSE; } -EGLenum eglQueryAPI() { +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI() { return EGL_OPENGL_ES_API; } -EGLBoolean eglWaitClient(void) { +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) { return EGL_FALSE; } -EGLBoolean eglReleaseThread(void) { +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) { return EGL_FALSE; } -EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, - EGLenum buftype, - EGLClientBuffer buffer, - EGLConfig config, - const EGLint* attrib_list) { +EGLAPI EGLSurface EGLAPIENTRY +eglCreatePbufferFromClientBuffer(EGLDisplay dpy, + EGLenum buftype, + EGLClientBuffer buffer, + EGLConfig config, + const EGLint* attrib_list) { return EGL_NO_SURFACE; } -EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) { +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, + EGLSurface surface, + EGLint attribute, + EGLint value) { return EGL_FALSE; } -EGLBoolean eglBindTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, + EGLSurface surface, + EGLint buffer) { return EGL_FALSE; } -EGLBoolean eglReleaseTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, + EGLSurface surface, + EGLint buffer) { return EGL_FALSE; } -EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) { +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) { return EGL_FALSE; } -EGLContext eglCreateContext(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) { +EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, + EGLConfig config, + EGLContext share_context, + const EGLint* attrib_list) { EGLint error_code = ValidateDisplayConfig(dpy, config); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_NO_CONTEXT); @@ -341,7 +349,8 @@ EGLContext eglCreateContext(EGLDisplay dpy, return EglSuccess(context); } -EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, + EGLContext ctx) { EGLint error_code = ValidateDisplayContext(dpy, ctx); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -351,10 +360,10 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { return EGL_TRUE; } -EGLBoolean eglMakeCurrent(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) { +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, + EGLSurface draw, + EGLSurface read, + EGLContext ctx) { if (ctx != EGL_NO_CONTEXT) { EGLint error_code = ValidateDisplaySurface(dpy, draw); if (error_code != EGL_SUCCESS) @@ -378,34 +387,35 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, return EGL_TRUE; } -EGLContext eglGetCurrentContext() { +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext() { return EGL_NO_CONTEXT; } -EGLSurface eglGetCurrentSurface(EGLint readdraw) { +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { return EGL_NO_SURFACE; } -EGLDisplay eglGetCurrentDisplay() { +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay() { return EGL_NO_DISPLAY; } -EGLBoolean eglQueryContext(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) { +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, + EGLContext ctx, + EGLint attribute, + EGLint* value) { return EGL_FALSE; } -EGLBoolean eglWaitGL() { +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL() { return EGL_FALSE; } -EGLBoolean eglWaitNative(EGLint engine) { +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { return EGL_FALSE; } -EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, + EGLSurface surface) { EGLint error_code = ValidateDisplaySurface(dpy, surface); if (error_code != EGL_SUCCESS) return EglError(error_code, EGL_FALSE); @@ -415,14 +425,14 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { return EglSuccess(EGL_TRUE); } -EGLBoolean eglCopyBuffers(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) { +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, + EGLSurface surface, + EGLNativePixmapType target) { return EGL_FALSE; } /* Now, define eglGetProcAddress using the generic function ptr. type */ -__eglMustCastToProperFunctionPointerType +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char* procname) { return reinterpret_cast<__eglMustCastToProperFunctionPointerType>( gles2::GetGLFunctionPointer(procname)); diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 650db2a..25cc26d 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -416,6 +416,43 @@ 'command_buffer/service/gles2_cmd_decoder_mock.cc', ], }, + { + # GN version: //gpu:command_buffer_gles2 + 'target_name': 'command_buffer_gles2', + 'type': 'shared_library', + 'dependencies': [ + '../base/base.gyp:base', + '../gpu/gpu.gyp:command_buffer_service', + '../ui/gfx/gfx.gyp:gfx_geometry', + '../ui/gl/gl.gyp:gl', + 'gles2_c_lib', + 'gles2_implementation', + ], + 'sources': [ + # Note: sources list duplicated in GN build. + # TODO(hendrikw): Move egl out of gles2_conform_support. + 'gles2_conform_support/egl/config.cc', + 'gles2_conform_support/egl/config.h', + 'gles2_conform_support/egl/display.cc', + 'gles2_conform_support/egl/display.h', + 'gles2_conform_support/egl/egl.cc', + 'gles2_conform_support/egl/surface.cc', + 'gles2_conform_support/egl/surface.h', + ], + 'conditions': [ + ['OS=="win"', { + 'defines': [ + 'EGLAPIENTRY=', + 'EGLAPI=__declspec(dllexport)', + ], + }, { # OS!="win" + 'defines': [ + 'EGLAPIENTRY=', + 'EGLAPI=__attribute__((visibility(\"default\")))' + ], + }, ], + ], + } ], 'conditions': [ ['component=="static_library"', { |