Changeset 65093 in webkit
- Timestamp:
- Aug 10, 2010 2:27:18 PM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r65085 r65093 1 2010-08-10 Kenneth Russell <kbr@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 Use Chromium OpenGL bindings rather than GLEW in WebGraphicsContextDefaultImpl 6 https://bugs.webkit.org/show_bug.cgi?id=43754 7 8 Deleted per-platform OpenGL context management code, now 9 abstracted via GLContext. Built and tested in Chromium with 10 --in-process-webgl flag. 11 12 * WebKit.gyp: 13 * src/GraphicsContext3D.cpp: 14 * src/WebGraphicsContext3DDefaultImpl.cpp: 15 (WebKit::WebGraphicsContext3DDefaultImpl::WebGraphicsContext3DDefaultImpl): 16 (WebKit::WebGraphicsContext3DDefaultImpl::~WebGraphicsContext3DDefaultImpl): 17 (WebKit::WebGraphicsContext3DDefaultImpl::initialize): 18 (WebKit::WebGraphicsContext3DDefaultImpl::validateAttributes): 19 (WebKit::WebGraphicsContext3DDefaultImpl::makeContextCurrent): 20 (WebKit::WebGraphicsContext3DDefaultImpl::reshape): 21 (WebKit::WebGraphicsContext3DDefaultImpl::readBackFramebuffer): 22 (WebKit::WebGraphicsContext3DDefaultImpl::copyTexImage2D): 23 (WebKit::WebGraphicsContext3DDefaultImpl::copyTexSubImage2D): 24 (WebKit::WebGraphicsContext3DDefaultImpl::readPixels): 25 (WebKit::WebGraphicsContext3DDefaultImpl::createBuffer): 26 (WebKit::WebGraphicsContext3DDefaultImpl::deleteBuffer): 27 * src/WebGraphicsContext3DDefaultImpl.h: 28 1 29 2010-08-10 Jian Li <jianli@chromium.org> 2 30 -
trunk/WebKit/chromium/WebKit.gyp
r65063 r65093 88 88 'dependencies': [ 89 89 '../../WebCore/WebCore.gyp/WebCore.gyp:webcore', 90 '<(chromium_src_dir)/app/app.gyp:app_base', # For GLContext 90 91 '<(chromium_src_dir)/skia/skia.gyp:skia', 91 92 '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi', … … 318 319 'src/GLES2ContextInternal.cpp', 319 320 'src/GLES2ContextInternal.h', 321 'src/GraphicsContext3D.cpp', 320 322 'src/gtk/WebFontInfo.cpp', 321 323 'src/gtk/WebFontInfo.h', … … 593 595 }], 594 596 ['"ENABLE_3D_CANVAS=1" in feature_defines', { 595 # Conditionally compile in GLEW and our GraphicsContext3D implementation.596 'sources+': [597 'src/GraphicsContext3D.cpp',598 '<(chromium_src_dir)/third_party/glew/src/glew.c'599 ],600 'include_dirs+': [601 '<(chromium_src_dir)/third_party/glew/include'602 ],603 'defines+': [604 'GLEW_STATIC=1',605 'GLEW_NO_GLU=1',606 ],607 597 'conditions': [ 608 598 ['OS=="mac"', { -
trunk/WebKit/chromium/src/GraphicsContext3D.cpp
r64990 r65093 86 86 // GraphicsContext3DInternal 87 87 88 // Uncomment this to render to a separate window for debugging89 // #define RENDER_TO_DEBUGGING_WINDOW90 91 88 class GraphicsContext3DInternal { 92 89 public: -
trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp
r64767 r65093 35 35 #include "WebGraphicsContext3DDefaultImpl.h" 36 36 37 #include "app/gfx/gl/gl_bindings.h" 38 #include "app/gfx/gl/gl_context.h" 37 39 #include "NotImplemented.h" 40 #include <wtf/PassOwnPtr.h> 38 41 39 42 #include <stdio.h> 40 43 #include <string.h> 41 44 42 #if OS(LINUX)43 #include <dlfcn.h>44 #endif45 46 45 namespace WebKit { 47 48 // Uncomment this to render to a separate window for debugging49 // #define RENDER_TO_DEBUGGING_WINDOW50 51 #if OS(DARWIN)52 #define USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER53 #endif54 55 bool WebGraphicsContext3DDefaultImpl::s_initializedGLEW = false;56 57 #if OS(LINUX)58 WebGraphicsContext3DDefaultImpl::GLConnection* WebGraphicsContext3DDefaultImpl::s_gl = 0;59 60 WebGraphicsContext3DDefaultImpl::GLConnection* WebGraphicsContext3DDefaultImpl::GLConnection::create()61 {62 Display* dpy = XOpenDisplay(0);63 if (!dpy) {64 printf("GraphicsContext3D: error opening X display\n");65 return 0;66 }67 68 // We use RTLD_GLOBAL semantics so that GLEW initialization works;69 // GLEW expects to be able to open the current process's handle70 // and do dlsym's of GL entry points from there.71 void* libGL = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);72 if (!libGL) {73 XCloseDisplay(dpy);74 printf("GraphicsContext3D: error opening libGL.so.1: %s\n", dlerror());75 return 0;76 }77 78 PFNGLXCHOOSEFBCONFIGPROC chooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) dlsym(libGL, "glXChooseFBConfig");79 PFNGLXCREATENEWCONTEXTPROC createNewContext = (PFNGLXCREATENEWCONTEXTPROC) dlsym(libGL, "glXCreateNewContext");80 PFNGLXCREATEPBUFFERPROC createPbuffer = (PFNGLXCREATEPBUFFERPROC) dlsym(libGL, "glXCreatePbuffer");81 PFNGLXDESTROYPBUFFERPROC destroyPbuffer = (PFNGLXDESTROYPBUFFERPROC) dlsym(libGL, "glXDestroyPbuffer");82 PFNGLXMAKECURRENTPROC makeCurrent = (PFNGLXMAKECURRENTPROC) dlsym(libGL, "glXMakeCurrent");83 PFNGLXDESTROYCONTEXTPROC destroyContext = (PFNGLXDESTROYCONTEXTPROC) dlsym(libGL, "glXDestroyContext");84 PFNGLXGETCURRENTCONTEXTPROC getCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC) dlsym(libGL, "glXGetCurrentContext");85 if (!chooseFBConfig || !createNewContext || !createPbuffer86 || !destroyPbuffer || !makeCurrent || !destroyContext87 || !getCurrentContext) {88 XCloseDisplay(dpy);89 dlclose(libGL);90 printf("GraphicsContext3D: error looking up bootstrapping entry points\n");91 return 0;92 }93 return new GLConnection(dpy,94 libGL,95 chooseFBConfig,96 createNewContext,97 createPbuffer,98 destroyPbuffer,99 makeCurrent,100 destroyContext,101 getCurrentContext);102 }103 104 WebGraphicsContext3DDefaultImpl::GLConnection::~GLConnection()105 {106 XCloseDisplay(m_display);107 dlclose(m_libGL);108 }109 110 #endif // OS(LINUX)111 46 112 47 WebGraphicsContext3DDefaultImpl::VertexAttribPointerState::VertexAttribPointerState() … … 135 70 #endif 136 71 , m_boundArrayBuffer(0) 137 #if OS(WINDOWS)138 , m_canvasWindow(0)139 , m_canvasDC(0)140 , m_contextObj(0)141 #elif PLATFORM(CG)142 , m_pbuffer(0)143 , m_contextObj(0)144 , m_renderOutput(0)145 #elif OS(LINUX)146 , m_contextObj(0)147 , m_pbuffer(0)148 #else149 #error Must port to your platform150 #endif151 72 { 152 73 } … … 156 77 if (m_initialized) { 157 78 makeContextCurrent(); 158 #ifndef RENDER_TO_DEBUGGING_WINDOW 79 159 80 if (m_attributes.antialias) { 160 81 glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer); … … 172 93 #endif 173 94 glDeleteFramebuffersEXT(1, &m_fbo); 174 #endif // !RENDER_TO_DEBUGGING_WINDOW 175 #if OS(WINDOWS) 176 wglewMakeCurrent(0, 0); 177 wglewDeleteContext(m_contextObj); 178 ReleaseDC(m_canvasWindow, m_canvasDC); 179 DestroyWindow(m_canvasWindow); 180 #elif PLATFORM(CG) 181 CGLSetCurrentContext(0); 182 CGLDestroyContext(m_contextObj); 183 CGLDestroyPBuffer(m_pbuffer); 184 if (m_renderOutput) 185 delete[] m_renderOutput; 186 #elif OS(LINUX) 187 s_gl->makeCurrent(0, 0); 188 s_gl->destroyContext(m_contextObj); 189 s_gl->destroyPbuffer(m_pbuffer); 190 #else 191 #error Must port to your platform 192 #endif 193 m_contextObj = 0; 95 96 m_glContext->Destroy(); 194 97 } 195 98 } … … 197 100 bool WebGraphicsContext3DDefaultImpl::initialize(WebGraphicsContext3D::Attributes attributes, WebView* webView) 198 101 { 199 #if OS(WINDOWS) 200 if (!s_initializedGLEW) { 201 // Do this only the first time through. 202 if (!wglewInit()) { 203 printf("WebGraphicsContext3DDefaultImpl: wglewInit failed\n"); 204 return false; 205 } 206 } 207 208 WNDCLASS wc; 209 if (!GetClassInfo(GetModuleHandle(0), L"CANVASGL", &wc)) { 210 ZeroMemory(&wc, sizeof(WNDCLASS)); 211 wc.style = CS_OWNDC; 212 wc.hInstance = GetModuleHandle(0); 213 wc.lpfnWndProc = DefWindowProc; 214 wc.lpszClassName = L"CANVASGL"; 215 216 if (!RegisterClass(&wc)) { 217 printf("WebGraphicsContext3DDefaultImpl: RegisterClass failed\n"); 218 return false; 219 } 220 } 221 222 m_canvasWindow = CreateWindow(L"CANVASGL", L"CANVASGL", 223 WS_CAPTION, 224 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 225 CW_USEDEFAULT, 0, 0, GetModuleHandle(0), 0); 226 if (!m_canvasWindow) { 227 printf("WebGraphicsContext3DDefaultImpl: CreateWindow failed\n"); 102 if (!gfx::GLContext::InitializeOneOff()) 228 103 return false; 229 } 230 231 // get the device context 232 m_canvasDC = GetDC(m_canvasWindow); 233 if (!m_canvasDC) { 234 printf("WebGraphicsContext3DDefaultImpl: GetDC failed\n"); 104 105 m_glContext = WTF::adoptPtr(gfx::GLContext::CreateOffscreenGLContext(0)); 106 if (!m_glContext) 235 107 return false; 236 }237 238 // find default pixel format239 PIXELFORMATDESCRIPTOR pfd;240 ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));241 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);242 pfd.nVersion = 1;243 #ifdef RENDER_TO_DEBUGGING_WINDOW244 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;245 #else246 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;247 #endif248 int pixelformat = ChoosePixelFormat(m_canvasDC, &pfd);249 250 // set the pixel format for the dc251 if (!SetPixelFormat(m_canvasDC, pixelformat, &pfd)) {252 printf("WebGraphicsContext3DDefaultImpl: SetPixelFormat failed\n");253 return false;254 }255 256 // create rendering context257 m_contextObj = wglewCreateContext(m_canvasDC);258 if (!m_contextObj) {259 printf("WebGraphicsContext3DDefaultImpl: wglCreateContext failed\n");260 return false;261 }262 263 if (!wglewMakeCurrent(m_canvasDC, m_contextObj)) {264 printf("WebGraphicsContext3DDefaultImpl: wglMakeCurrent failed\n");265 return false;266 }267 268 #ifdef RENDER_TO_DEBUGGING_WINDOW269 typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);270 PFNWGLSWAPINTERVALEXTPROC setSwapInterval = 0;271 setSwapInterval = (PFNWGLSWAPINTERVALEXTPROC) wglewGetProcAddress("wglSwapIntervalEXT");272 if (setSwapInterval)273 setSwapInterval(1);274 #endif // RENDER_TO_DEBUGGING_WINDOW275 276 #elif PLATFORM(CG)277 // Create a 1x1 pbuffer and associated context to bootstrap things278 CGLPixelFormatAttribute attribs[] = {279 (CGLPixelFormatAttribute) kCGLPFAPBuffer,280 (CGLPixelFormatAttribute) 0281 };282 CGLPixelFormatObj pixelFormat;283 GLint numPixelFormats;284 if (CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats) != kCGLNoError) {285 printf("WebGraphicsContext3DDefaultImpl: error choosing pixel format\n");286 return false;287 }288 if (!pixelFormat) {289 printf("WebGraphicsContext3DDefaultImpl: no pixel format selected\n");290 return false;291 }292 CGLContextObj context;293 CGLError res = CGLCreateContext(pixelFormat, 0, &context);294 CGLDestroyPixelFormat(pixelFormat);295 if (res != kCGLNoError) {296 printf("WebGraphicsContext3DDefaultImpl: error creating context\n");297 return false;298 }299 CGLPBufferObj pbuffer;300 if (CGLCreatePBuffer(1, 1, GL_TEXTURE_2D, GL_RGBA, 0, &pbuffer) != kCGLNoError) {301 CGLDestroyContext(context);302 printf("WebGraphicsContext3DDefaultImpl: error creating pbuffer\n");303 return false;304 }305 if (CGLSetPBuffer(context, pbuffer, 0, 0, 0) != kCGLNoError) {306 CGLDestroyContext(context);307 CGLDestroyPBuffer(pbuffer);308 printf("WebGraphicsContext3DDefaultImpl: error attaching pbuffer to context\n");309 return false;310 }311 if (CGLSetCurrentContext(context) != kCGLNoError) {312 CGLDestroyContext(context);313 CGLDestroyPBuffer(pbuffer);314 printf("WebGraphicsContext3DDefaultImpl: error making context current\n");315 return false;316 }317 m_pbuffer = pbuffer;318 m_contextObj = context;319 #elif OS(LINUX)320 if (!s_gl) {321 s_gl = GLConnection::create();322 if (!s_gl)323 return false;324 }325 326 int configAttrs[] = {327 GLX_DRAWABLE_TYPE,328 GLX_PBUFFER_BIT,329 GLX_RENDER_TYPE,330 GLX_RGBA_BIT,331 GLX_DOUBLEBUFFER,332 0,333 0334 };335 int nelements = 0;336 GLXFBConfig* config = s_gl->chooseFBConfig(0, configAttrs, &nelements);337 if (!config) {338 printf("WebGraphicsContext3DDefaultImpl: glXChooseFBConfig failed\n");339 return false;340 }341 if (!nelements) {342 printf("WebGraphicsContext3DDefaultImpl: glXChooseFBConfig returned 0 elements\n");343 XFree(config);344 return false;345 }346 GLXContext context = s_gl->createNewContext(config[0], GLX_RGBA_TYPE, 0, True);347 if (!context) {348 printf("WebGraphicsContext3DDefaultImpl: glXCreateNewContext failed\n");349 XFree(config);350 return false;351 }352 int pbufferAttrs[] = {353 GLX_PBUFFER_WIDTH,354 1,355 GLX_PBUFFER_HEIGHT,356 1,357 0358 };359 GLXPbuffer pbuffer = s_gl->createPbuffer(config[0], pbufferAttrs);360 XFree(config);361 if (!pbuffer) {362 printf("WebGraphicsContext3DDefaultImpl: glxCreatePbuffer failed\n");363 return false;364 }365 if (!s_gl->makeCurrent(pbuffer, context)) {366 printf("WebGraphicsContext3DDefaultImpl: glXMakeCurrent failed\n");367 return false;368 }369 m_contextObj = context;370 m_pbuffer = pbuffer;371 #else372 #error Must port to your platform373 #endif374 375 if (!s_initializedGLEW) {376 // Initialize GLEW and check for GL 2.0 support by the drivers.377 GLenum glewInitResult = glewInit();378 if (glewInitResult != GLEW_OK) {379 printf("WebGraphicsContext3DDefaultImpl: GLEW initialization failed\n");380 return false;381 }382 if (!glewIsSupported("GL_VERSION_2_0")) {383 printf("WebGraphicsContext3DDefaultImpl: OpenGL 2.0 not supported\n");384 return false;385 }386 s_initializedGLEW = true;387 }388 108 389 109 m_attributes = attributes; … … 424 144 bool WebGraphicsContext3DDefaultImpl::makeContextCurrent() 425 145 { 426 #if OS(WINDOWS) 427 if (wglewGetCurrentContext() != m_contextObj) 428 if (wglewMakeCurrent(m_canvasDC, m_contextObj)) 429 return true; 430 #elif PLATFORM(CG) 431 if (CGLGetCurrentContext() != m_contextObj) 432 if (CGLSetCurrentContext(m_contextObj) == kCGLNoError) 433 return true; 434 #elif OS(LINUX) 435 if (s_gl->getCurrentContext() != m_contextObj) 436 if (s_gl->makeCurrent(m_pbuffer, m_contextObj)) 437 return true; 438 #else 439 #error Must port to your platform 440 #endif 441 return false; 146 return m_glContext->MakeCurrent(); 442 147 } 443 148 … … 501 206 void WebGraphicsContext3DDefaultImpl::reshape(int width, int height) 502 207 { 503 #ifdef RENDER_TO_DEBUGGING_WINDOW504 SetWindowPos(m_canvasWindow, HWND_TOP, 0, 0, width, height,505 SWP_NOMOVE);506 ShowWindow(m_canvasWindow, SW_SHOW);507 #endif508 509 208 m_cachedWidth = width; 510 209 m_cachedHeight = height; 511 210 makeContextCurrent(); 512 211 513 #ifndef RENDER_TO_DEBUGGING_WINDOW514 #ifdef USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER515 // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on Mac OS X516 GLenum target = GL_TEXTURE_RECTANGLE_ARB;517 #else518 212 GLenum target = GL_TEXTURE_2D; 519 #endif 213 520 214 if (!m_texture) { 521 215 // Generate the texture object … … 659 353 if (mustRestoreFBO) 660 354 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); 661 #endif // RENDER_TO_DEBUGGING_WINDOW662 355 663 356 #ifdef FLIP_FRAMEBUFFER_VERTICALLY … … 701 394 makeContextCurrent(); 702 395 703 #ifdef RENDER_TO_DEBUGGING_WINDOW704 SwapBuffers(m_canvasDC);705 #else706 396 // Earlier versions of this code used the GPU to flip the 707 397 // framebuffer vertically before reading it back for compositing … … 733 423 } 734 424 735 #if PLATFORM(SKIA) 425 // FIXME: OpenGL ES 2 does not support GL_BGRA so this fails when 426 // using that backend. 736 427 glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels); 737 #elif PLATFORM(CG)738 glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);739 #else740 #error Must port to your platform741 #endif742 428 743 429 if (mustRestorePackAlignment) … … 752 438 #endif 753 439 754 #endif // RENDER_TO_DEBUGGING_WINDOW755 440 return true; 756 441 } … … 917 602 { 918 603 makeContextCurrent(); 919 #ifndef RENDER_TO_DEBUGGING_WINDOW 604 920 605 if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) { 921 606 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); … … 924 609 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); 925 610 } 926 #endif 611 927 612 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); 928 #ifndef RENDER_TO_DEBUGGING_WINDOW 613 929 614 if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) 930 615 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); 931 #endif932 616 } 933 617 … … 936 620 { 937 621 makeContextCurrent(); 938 #ifndef RENDER_TO_DEBUGGING_WINDOW 622 939 623 if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) { 940 624 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); … … 943 627 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); 944 628 } 945 #endif 629 946 630 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); 947 #ifndef RENDER_TO_DEBUGGING_WINDOW 631 948 632 if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) 949 633 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); 950 #endif951 634 } 952 635 … … 1243 926 DELEGATE_TO_GL_1R(isEnabled, IsEnabled, unsigned long, bool) 1244 927 1245 DELEGATE_TO_GL_1R(isFramebuffer, IsFramebuffer , WebGLId, bool)928 DELEGATE_TO_GL_1R(isFramebuffer, IsFramebufferEXT, WebGLId, bool) 1246 929 1247 930 DELEGATE_TO_GL_1R(isProgram, IsProgram, WebGLId, bool) 1248 931 1249 DELEGATE_TO_GL_1R(isRenderbuffer, IsRenderbuffer , WebGLId, bool)932 DELEGATE_TO_GL_1R(isRenderbuffer, IsRenderbufferEXT, WebGLId, bool) 1250 933 1251 934 DELEGATE_TO_GL_1R(isShader, IsShader, WebGLId, bool) … … 1267 950 // all previous rendering calls should be done before reading pixels. 1268 951 glFlush(); 1269 #ifndef RENDER_TO_DEBUGGING_WINDOW1270 952 if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) { 1271 953 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); … … 1275 957 glFlush(); 1276 958 } 1277 #endif 959 1278 960 glReadPixels(x, y, width, height, format, type, pixels); 1279 #ifndef RENDER_TO_DEBUGGING_WINDOW 961 1280 962 if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) 1281 963 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); 1282 #endif1283 964 } 1284 965 … … 1432 1113 makeContextCurrent(); 1433 1114 GLuint o; 1434 glGenBuffers (1, &o);1115 glGenBuffersARB(1, &o); 1435 1116 return o; 1436 1117 } … … 1471 1152 { 1472 1153 makeContextCurrent(); 1473 glDeleteBuffers (1, &buffer);1154 glDeleteBuffersARB(1, &buffer); 1474 1155 } 1475 1156 -
trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h
r64767 r65093 37 37 38 38 #include <wtf/ListHashSet.h> 39 40 #if OS(WINDOWS) 41 #include <windows.h> 42 #endif 43 44 #include "GL/glew.h" 45 #if OS(WINDOWS) 46 #include "GL/wglew.h" 47 #endif 48 49 #if PLATFORM(CG) 50 #include <OpenGL/OpenGL.h> 51 #else 39 #include <wtf/OwnPtr.h> 40 41 #if !PLATFORM(CG) 52 42 #define FLIP_FRAMEBUFFER_VERTICALLY 53 43 #endif 54 55 #if OS(LINUX) 56 #include "GL/glxew.h" 57 #endif 44 namespace gfx { 45 class GLContext; 46 } 58 47 59 48 namespace WebKit { … … 324 313 ListHashSet<unsigned long> m_syntheticErrors; 325 314 326 static bool s_initializedGLEW; 327 #if OS(WINDOWS) 328 HWND m_canvasWindow; 329 HDC m_canvasDC; 330 HGLRC m_contextObj; 331 #elif PLATFORM(CG) 332 CGLPBufferObj m_pbuffer; 333 CGLContextObj m_contextObj; 334 unsigned char* m_renderOutput; 335 #elif OS(LINUX) 336 GLXContext m_contextObj; 337 GLXPbuffer m_pbuffer; 338 339 // In order to avoid problems caused by linking against libGL, we 340 // dynamically look up all the symbols we need. 341 // http://code.google.com/p/chromium/issues/detail?id=16800 342 class GLConnection { 343 public: 344 ~GLConnection(); 345 346 static GLConnection* create(); 347 348 GLXFBConfig* chooseFBConfig(int screen, const int *attrib_list, int *nelements) 349 { 350 return m_glXChooseFBConfig(m_display, screen, attrib_list, nelements); 351 } 352 353 GLXContext createNewContext(GLXFBConfig config, int renderType, GLXContext shareList, Bool direct) 354 { 355 return m_glXCreateNewContext(m_display, config, renderType, shareList, direct); 356 } 357 358 GLXPbuffer createPbuffer(GLXFBConfig config, const int *attribList) 359 { 360 return m_glXCreatePbuffer(m_display, config, attribList); 361 } 362 363 void destroyPbuffer(GLXPbuffer pbuf) 364 { 365 m_glXDestroyPbuffer(m_display, pbuf); 366 } 367 368 Bool makeCurrent(GLXDrawable drawable, GLXContext ctx) 369 { 370 return m_glXMakeCurrent(m_display, drawable, ctx); 371 } 372 373 void destroyContext(GLXContext ctx) 374 { 375 m_glXDestroyContext(m_display, ctx); 376 } 377 378 GLXContext getCurrentContext() 379 { 380 return m_glXGetCurrentContext(); 381 } 382 383 private: 384 Display* m_display; 385 void* m_libGL; 386 PFNGLXCHOOSEFBCONFIGPROC m_glXChooseFBConfig; 387 PFNGLXCREATENEWCONTEXTPROC m_glXCreateNewContext; 388 PFNGLXCREATEPBUFFERPROC m_glXCreatePbuffer; 389 PFNGLXDESTROYPBUFFERPROC m_glXDestroyPbuffer; 390 typedef Bool (* PFNGLXMAKECURRENTPROC)(Display* dpy, GLXDrawable drawable, GLXContext ctx); 391 PFNGLXMAKECURRENTPROC m_glXMakeCurrent; 392 typedef void (* PFNGLXDESTROYCONTEXTPROC)(Display* dpy, GLXContext ctx); 393 PFNGLXDESTROYCONTEXTPROC m_glXDestroyContext; 394 typedef GLXContext (* PFNGLXGETCURRENTCONTEXTPROC)(void); 395 PFNGLXGETCURRENTCONTEXTPROC m_glXGetCurrentContext; 396 397 GLConnection(Display* display, 398 void* libGL, 399 PFNGLXCHOOSEFBCONFIGPROC chooseFBConfig, 400 PFNGLXCREATENEWCONTEXTPROC createNewContext, 401 PFNGLXCREATEPBUFFERPROC createPbuffer, 402 PFNGLXDESTROYPBUFFERPROC destroyPbuffer, 403 PFNGLXMAKECURRENTPROC makeCurrent, 404 PFNGLXDESTROYCONTEXTPROC destroyContext, 405 PFNGLXGETCURRENTCONTEXTPROC getCurrentContext) 406 : m_libGL(libGL) 407 , m_display(display) 408 , m_glXChooseFBConfig(chooseFBConfig) 409 , m_glXCreateNewContext(createNewContext) 410 , m_glXCreatePbuffer(createPbuffer) 411 , m_glXDestroyPbuffer(destroyPbuffer) 412 , m_glXMakeCurrent(makeCurrent) 413 , m_glXDestroyContext(destroyContext) 414 , m_glXGetCurrentContext(getCurrentContext) 415 { 416 } 417 }; 418 419 static GLConnection* s_gl; 420 #else 421 #error Must port WebGraphicsContext3DDefaultImpl to your platform 315 OwnPtr<gfx::GLContext> m_glContext; 316 }; 317 318 } // namespace WebKit 319 320 #endif // ENABLE(3D_CANVAS) 321 422 322 #endif 423 };424 425 } // namespace WebKit426 427 #endif // ENABLE(3D_CANVAS)428 429 #endif
Note: See TracChangeset
for help on using the changeset viewer.