Changeset 65093 in webkit


Ignore:
Timestamp:
Aug 10, 2010 2:27:18 PM (14 years ago)
Author:
kbr@google.com
Message:

2010-08-10 Kenneth Russell <kbr@google.com>

Reviewed by Dimitri Glazkov.

Use Chromium OpenGL bindings rather than GLEW in WebGraphicsContextDefaultImpl
https://bugs.webkit.org/show_bug.cgi?id=43754

Deleted per-platform OpenGL context management code, now
abstracted via GLContext. Built and tested in Chromium with
--in-process-webgl flag.

  • WebKit.gyp:
  • src/GraphicsContext3D.cpp:
  • src/WebGraphicsContext3DDefaultImpl.cpp: (WebKit::WebGraphicsContext3DDefaultImpl::WebGraphicsContext3DDefaultImpl): (WebKit::WebGraphicsContext3DDefaultImpl::~WebGraphicsContext3DDefaultImpl): (WebKit::WebGraphicsContext3DDefaultImpl::initialize): (WebKit::WebGraphicsContext3DDefaultImpl::validateAttributes): (WebKit::WebGraphicsContext3DDefaultImpl::makeContextCurrent): (WebKit::WebGraphicsContext3DDefaultImpl::reshape): (WebKit::WebGraphicsContext3DDefaultImpl::readBackFramebuffer): (WebKit::WebGraphicsContext3DDefaultImpl::copyTexImage2D): (WebKit::WebGraphicsContext3DDefaultImpl::copyTexSubImage2D): (WebKit::WebGraphicsContext3DDefaultImpl::readPixels): (WebKit::WebGraphicsContext3DDefaultImpl::createBuffer): (WebKit::WebGraphicsContext3DDefaultImpl::deleteBuffer):
  • src/WebGraphicsContext3DDefaultImpl.h:
Location:
trunk/WebKit/chromium
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r65085 r65093  
     12010-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
    1292010-08-10  Jian Li  <jianli@chromium.org>
    230
  • trunk/WebKit/chromium/WebKit.gyp

    r65063 r65093  
    8888            'dependencies': [
    8989                '../../WebCore/WebCore.gyp/WebCore.gyp:webcore',
     90                '<(chromium_src_dir)/app/app.gyp:app_base', # For GLContext
    9091                '<(chromium_src_dir)/skia/skia.gyp:skia',
    9192                '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
     
    318319                'src/GLES2ContextInternal.cpp',
    319320                'src/GLES2ContextInternal.h',
     321                'src/GraphicsContext3D.cpp',
    320322                'src/gtk/WebFontInfo.cpp',
    321323                'src/gtk/WebFontInfo.h',
     
    593595                }],
    594596                ['"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                     ],
    607597                    'conditions': [
    608598                        ['OS=="mac"', {
  • trunk/WebKit/chromium/src/GraphicsContext3D.cpp

    r64990 r65093  
    8686// GraphicsContext3DInternal
    8787
    88 // Uncomment this to render to a separate window for debugging
    89 // #define RENDER_TO_DEBUGGING_WINDOW
    90 
    9188class GraphicsContext3DInternal {
    9289public:
  • trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp

    r64767 r65093  
    3535#include "WebGraphicsContext3DDefaultImpl.h"
    3636
     37#include "app/gfx/gl/gl_bindings.h"
     38#include "app/gfx/gl/gl_context.h"
    3739#include "NotImplemented.h"
     40#include <wtf/PassOwnPtr.h>
    3841
    3942#include <stdio.h>
    4043#include <string.h>
    4144
    42 #if OS(LINUX)
    43 #include <dlfcn.h>
    44 #endif
    45 
    4645namespace WebKit {
    47 
    48 // Uncomment this to render to a separate window for debugging
    49 // #define RENDER_TO_DEBUGGING_WINDOW
    50 
    51 #if OS(DARWIN)
    52 #define USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER
    53 #endif
    54 
    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 handle
    70     // 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 || !createPbuffer
    86         || !destroyPbuffer || !makeCurrent || !destroyContext
    87         || !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)
    11146
    11247WebGraphicsContext3DDefaultImpl::VertexAttribPointerState::VertexAttribPointerState()
     
    13570#endif
    13671    , 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 #else
    149 #error Must port to your platform
    150 #endif
    15172{
    15273}
     
    15677    if (m_initialized) {
    15778        makeContextCurrent();
    158 #ifndef RENDER_TO_DEBUGGING_WINDOW
     79
    15980        if (m_attributes.antialias) {
    16081            glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer);
     
    17293#endif
    17394        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();
    19497    }
    19598}
     
    197100bool WebGraphicsContext3DDefaultImpl::initialize(WebGraphicsContext3D::Attributes attributes, WebView* webView)
    198101{
    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())
    228103        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)
    235107        return false;
    236     }
    237 
    238     // find default pixel format
    239     PIXELFORMATDESCRIPTOR pfd;
    240     ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
    241     pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
    242     pfd.nVersion = 1;
    243 #ifdef RENDER_TO_DEBUGGING_WINDOW
    244     pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
    245 #else
    246     pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
    247 #endif
    248     int pixelformat = ChoosePixelFormat(m_canvasDC, &pfd);
    249 
    250     // set the pixel format for the dc
    251     if (!SetPixelFormat(m_canvasDC, pixelformat, &pfd)) {
    252         printf("WebGraphicsContext3DDefaultImpl: SetPixelFormat failed\n");
    253         return false;
    254     }
    255 
    256     // create rendering context
    257     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_WINDOW
    269     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_WINDOW
    275 
    276 #elif PLATFORM(CG)
    277     // Create a 1x1 pbuffer and associated context to bootstrap things
    278     CGLPixelFormatAttribute attribs[] = {
    279         (CGLPixelFormatAttribute) kCGLPFAPBuffer,
    280         (CGLPixelFormatAttribute) 0
    281     };
    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         0
    334     };
    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         0
    358     };
    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 #else
    372 #error Must port to your platform
    373 #endif
    374 
    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     }
    388108
    389109    m_attributes = attributes;
     
    424144bool WebGraphicsContext3DDefaultImpl::makeContextCurrent()
    425145{
    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();
    442147}
    443148
     
    501206void WebGraphicsContext3DDefaultImpl::reshape(int width, int height)
    502207{
    503 #ifdef RENDER_TO_DEBUGGING_WINDOW
    504     SetWindowPos(m_canvasWindow, HWND_TOP, 0, 0, width, height,
    505                  SWP_NOMOVE);
    506     ShowWindow(m_canvasWindow, SW_SHOW);
    507 #endif
    508 
    509208    m_cachedWidth = width;
    510209    m_cachedHeight = height;
    511210    makeContextCurrent();
    512211
    513 #ifndef RENDER_TO_DEBUGGING_WINDOW
    514 #ifdef USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER
    515     // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on Mac OS X
    516     GLenum target = GL_TEXTURE_RECTANGLE_ARB;
    517 #else
    518212    GLenum target = GL_TEXTURE_2D;
    519 #endif
     213
    520214    if (!m_texture) {
    521215        // Generate the texture object
     
    659353    if (mustRestoreFBO)
    660354        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    661 #endif // RENDER_TO_DEBUGGING_WINDOW
    662355
    663356#ifdef FLIP_FRAMEBUFFER_VERTICALLY
     
    701394    makeContextCurrent();
    702395
    703 #ifdef RENDER_TO_DEBUGGING_WINDOW
    704     SwapBuffers(m_canvasDC);
    705 #else
    706396    // Earlier versions of this code used the GPU to flip the
    707397    // framebuffer vertically before reading it back for compositing
     
    733423    }
    734424
    735 #if PLATFORM(SKIA)
     425    // FIXME: OpenGL ES 2 does not support GL_BGRA so this fails when
     426    // using that backend.
    736427    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 #else
    740 #error Must port to your platform
    741 #endif
    742428
    743429    if (mustRestorePackAlignment)
     
    752438#endif
    753439
    754 #endif // RENDER_TO_DEBUGGING_WINDOW
    755440    return true;
    756441}
     
    917602{
    918603    makeContextCurrent();
    919 #ifndef RENDER_TO_DEBUGGING_WINDOW
     604
    920605    if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) {
    921606        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     
    924609        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    925610    }
    926 #endif
     611
    927612    glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
    928 #ifndef RENDER_TO_DEBUGGING_WINDOW
     613
    929614    if (m_attributes.antialias && m_boundFBO == m_multisampleFBO)
    930615        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    931 #endif
    932616}
    933617
     
    936620{
    937621    makeContextCurrent();
    938 #ifndef RENDER_TO_DEBUGGING_WINDOW
     622
    939623    if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) {
    940624        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     
    943627        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    944628    }
    945 #endif
     629
    946630    glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
    947 #ifndef RENDER_TO_DEBUGGING_WINDOW
     631
    948632    if (m_attributes.antialias && m_boundFBO == m_multisampleFBO)
    949633        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    950 #endif
    951634}
    952635
     
    1243926DELEGATE_TO_GL_1R(isEnabled, IsEnabled, unsigned long, bool)
    1244927
    1245 DELEGATE_TO_GL_1R(isFramebuffer, IsFramebuffer, WebGLId, bool)
     928DELEGATE_TO_GL_1R(isFramebuffer, IsFramebufferEXT, WebGLId, bool)
    1246929
    1247930DELEGATE_TO_GL_1R(isProgram, IsProgram, WebGLId, bool)
    1248931
    1249 DELEGATE_TO_GL_1R(isRenderbuffer, IsRenderbuffer, WebGLId, bool)
     932DELEGATE_TO_GL_1R(isRenderbuffer, IsRenderbufferEXT, WebGLId, bool)
    1250933
    1251934DELEGATE_TO_GL_1R(isShader, IsShader, WebGLId, bool)
     
    1267950    // all previous rendering calls should be done before reading pixels.
    1268951    glFlush();
    1269 #ifndef RENDER_TO_DEBUGGING_WINDOW
    1270952    if (m_attributes.antialias && m_boundFBO == m_multisampleFBO) {
    1271953        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     
    1275957        glFlush();
    1276958    }
    1277 #endif
     959
    1278960    glReadPixels(x, y, width, height, format, type, pixels);
    1279 #ifndef RENDER_TO_DEBUGGING_WINDOW
     961
    1280962    if (m_attributes.antialias && m_boundFBO == m_multisampleFBO)
    1281963        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    1282 #endif
    1283964}
    1284965
     
    14321113    makeContextCurrent();
    14331114    GLuint o;
    1434     glGenBuffers(1, &o);
     1115    glGenBuffersARB(1, &o);
    14351116    return o;
    14361117}
     
    14711152{
    14721153    makeContextCurrent();
    1473     glDeleteBuffers(1, &buffer);
     1154    glDeleteBuffersARB(1, &buffer);
    14741155}
    14751156
  • trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h

    r64767 r65093  
    3737
    3838#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)
    5242#define FLIP_FRAMEBUFFER_VERTICALLY
    5343#endif
    54 
    55 #if OS(LINUX)
    56 #include "GL/glxew.h"
    57 #endif
     44namespace gfx {
     45class GLContext;
     46}
    5847
    5948namespace WebKit {
     
    324313    ListHashSet<unsigned long> m_syntheticErrors;
    325314
    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
    422322#endif
    423 };
    424 
    425 } // namespace WebKit
    426 
    427 #endif // ENABLE(3D_CANVAS)
    428 
    429 #endif
Note: See TracChangeset for help on using the changeset viewer.