Changeset 126635 in webkit
- Timestamp:
- Aug 24, 2012 3:30:16 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126631 r126635 1 2012-08-24 Helder Correia <helder.correia@nokia.com>, Roland Takacs <rtakacs@inf.u-szeged.hu> 2 3 [Texmap] Move TextureMapperGL to use GraphicsContext3D 4 https://bugs.webkit.org/show_bug.cgi?id=78672 5 6 Reviewed by Noam Rosenthal. 7 8 This is part of a several patch-refactoring. 9 10 Introduce additional logic in GraphicsContext3DQt to support a 11 new RenderToCurrentGLContext RenderStyle. This is necessary to 12 use GC3D for other things than WebGL, like TextureMapper. 13 14 The GC3D constructor now accepts a RenderStyle instead of the 15 boolean renderDirectlyToHostWindow and thus mimics create()'s 16 signature. This has been changed for all ports in this patch. 17 18 A new GC3D::createForCurrentGLContext() builder was 19 introduced to better abstract the goal of using GC3D with the 20 current context. 21 22 The patch was originally developed by Helder Correia and finished 23 by Roland Takacs. 24 25 No new tests, refactoring. 26 1 27 2012-08-24 Sheriff Bot <webkit.review.bot@gmail.com> 2 28 -
trunk/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp
r121268 r126635 44 44 namespace WebCore { 45 45 46 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, bool)46 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle) 47 47 { 48 48 } -
trunk/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp
r121268 r126635 78 78 PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer) 79 79 { 80 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0 , false /* onscreen */));80 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0)); 81 81 82 82 OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r125690 r126635 459 459 enum RenderStyle { 460 460 RenderOffscreen, 461 RenderDirectlyToHostWindow 461 RenderDirectlyToHostWindow, 462 RenderToCurrentGLContext 462 463 }; 463 464 … … 478 479 479 480 static PassRefPtr<GraphicsContext3D> create(Attributes, HostWindow*, RenderStyle = RenderOffscreen); 481 static PassRefPtr<GraphicsContext3D> createForCurrentGLContext(); 480 482 ~GraphicsContext3D(); 481 483 … … 868 870 869 871 private: 870 GraphicsContext3D(Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow);872 GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen); 871 873 872 874 // Each platform must provide an implementation of this method. … … 983 985 984 986 Attributes m_attrs; 987 RenderStyle m_renderStyle; 985 988 Vector<Vector<float> > m_vertexArray; 986 989 -
trunk/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp
r125563 r126635 48 48 return 0; 49 49 50 return adoptRef(new GraphicsContext3D(attribs, hostWindow, false));51 } 52 53 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToHostWindow)50 return adoptRef(new GraphicsContext3D(attribs, hostWindow, renderStyle)); 51 } 52 53 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle) 54 54 : m_currentWidth(0) 55 55 , m_currentHeight(0) … … 68 68 , m_isImaginationHardware(0) 69 69 { 70 if ( !renderDirectlyToHostWindow) {70 if (renderStyle != RenderDirectlyToHostWindow) { 71 71 #if USE(ACCELERATED_COMPOSITING) 72 72 m_compositingLayer = WebGLLayerWebKitThread::create(); -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r125203 r126635 62 62 return 0; 63 63 64 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));64 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle)); 65 65 return context.release(); 66 66 } 67 67 68 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, bool)68 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle) 69 69 : m_currentWidth(0) 70 70 , m_currentHeight(0) -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp
r122250 r126635 43 43 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) 44 44 { 45 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));45 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle)); 46 46 return context.release(); 47 47 } 48 48 49 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool)49 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) 50 50 { 51 51 notImplemented(); -
trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
r122958 r126635 37 37 return 0; 38 38 39 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, render DirectlyToEvasGLObject));39 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); 40 40 context->m_private = internal.release(); 41 41 return context.release(); 42 42 } 43 43 44 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow)44 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) 45 45 : m_currentWidth(0) 46 46 , m_currentHeight(0) -
trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
r126477 r126635 93 93 if (renderStyle == RenderDirectlyToHostWindow) 94 94 return 0; 95 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));95 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); 96 96 return context->m_contextObj ? context.release() : 0; 97 97 } 98 98 99 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)99 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) 100 100 : m_currentWidth(0) 101 101 , m_currentHeight(0) … … 117 117 { 118 118 UNUSED_PARAM(hostWindow); 119 UNUSED_PARAM(renderStyle); 119 120 120 121 Vector<CGLPixelFormatAttribute> attribs; -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
r125617 r126635 71 71 namespace WebCore { 72 72 73 PassRefPtr<GraphicsContext3D> GraphicsContext3D::createForCurrentGLContext() 74 { 75 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(Attributes(), 0, GraphicsContext3D::RenderToCurrentGLContext)); 76 return context->m_private ? context.release() : 0; 77 } 78 73 79 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension) 74 80 { -
trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
r125773 r126635 62 62 { 63 63 public: 64 GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow* );64 GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle); 65 65 ~GraphicsContext3DPrivate(); 66 66 … … 77 77 void blitMultisampleFramebufferAndRestoreContext() const; 78 78 bool makeCurrentIfNeeded() const; 79 void createOffscreenBuffers(); 80 void initializeANGLE(); 79 81 void createGraphicsSurfaces(const IntSize&); 80 82 … … 105 107 #endif 106 108 107 GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow )109 GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) 108 110 : m_context(context) 109 111 , m_hostWindow(hostWindow) … … 119 121 120 122 makeCurrentIfNeeded(); 123 return; 124 } 125 126 if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) { 127 m_platformContext = QOpenGLContext::currentContext(); 128 m_surface = m_platformContext->surface(); 121 129 return; 122 130 } … … 146 154 } 147 155 156 void GraphicsContext3DPrivate::createOffscreenBuffers() 157 { 158 glGenFramebuffers(/* count */ 1, &m_context->m_fbo); 159 160 glGenTextures(1, &m_context->m_texture); 161 glBindTexture(GraphicsContext3D::TEXTURE_2D, m_context->m_texture); 162 glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); 163 glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); 164 glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); 165 glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); 166 glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); 167 168 // Create a multisample FBO. 169 if (m_context->m_attrs.antialias) { 170 glGenFramebuffers(1, &m_context->m_multisampleFBO); 171 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO); 172 m_context->m_boundFBO = m_context->m_multisampleFBO; 173 glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer); 174 if (m_context->m_attrs.stencil || m_context->m_attrs.depth) 175 glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer); 176 } else { 177 // Bind canvas FBO. 178 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); 179 m_context->m_boundFBO = m_context->m_fbo; 180 #if USE(OPENGL_ES_2) 181 if (m_context->m_attrs.depth) 182 glGenRenderbuffers(1, &m_context->m_depthBuffer); 183 if (m_context->m_attrs.stencil) 184 glGenRenderbuffers(1, &m_context->m_stencilBuffer); 185 #endif 186 if (m_context->m_attrs.stencil || m_context->m_attrs.depth) 187 glGenRenderbuffers(1, &m_context->m_depthStencilBuffer); 188 } 189 } 190 191 void GraphicsContext3DPrivate::initializeANGLE() 192 { 193 ShBuiltInResources ANGLEResources; 194 ShInitBuiltInResources(&ANGLEResources); 195 196 m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs); 197 m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors); 198 m_context->getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors); 199 m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits); 200 m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); 201 m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits); 202 m_context->getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors); 203 204 // Always set to 1 for OpenGL ES. 205 ANGLEResources.MaxDrawBuffers = 1; 206 m_context->m_compiler.setResources(ANGLEResources); 207 } 208 148 209 GraphicsContext3DPrivate::~GraphicsContext3DPrivate() 149 210 { 150 delete m_surface; 151 m_surface = 0; 152 // Platform context is assumed to be owned by surface. 153 m_platformContext = 0; 211 if (m_hostWindow) { 212 delete m_surface; 213 m_surface = 0; 214 // Platform context is assumed to be owned by surface. 215 m_platformContext = 0; 216 } 154 217 } 155 218 … … 292 355 if (renderStyle == RenderDirectlyToHostWindow) 293 356 return 0; 294 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));357 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); 295 358 return context->m_private ? context.release() : 0; 296 359 } 297 360 298 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)361 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) 299 362 : m_currentWidth(0) 300 363 , m_currentHeight(0) 301 364 , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT) 302 365 , m_attrs(attrs) 366 , m_renderStyle(renderStyle) 303 367 , m_texture(0) 304 368 , m_compositorTexture(0) … … 317 381 , m_multisampleDepthStencilBuffer(0) 318 382 , m_multisampleColorBuffer(0) 319 , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow )))383 , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle))) 320 384 { 321 385 validateAttributes(); … … 338 402 } 339 403 340 // Create buffers for the canvas FBO. 341 glGenFramebuffers(/* count */ 1, &m_fbo); 342 343 glGenTextures(1, &m_texture); 344 glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture); 345 glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); 346 glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); 347 glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); 348 glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); 349 glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); 350 351 // Create a multisample FBO. 352 if (m_attrs.antialias) { 353 glGenFramebuffers(1, &m_multisampleFBO); 354 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); 355 m_boundFBO = m_multisampleFBO; 356 glGenRenderbuffers(1, &m_multisampleColorBuffer); 357 if (m_attrs.stencil || m_attrs.depth) 358 glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer); 359 } else { 360 // Bind canvas FBO. 361 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 362 m_boundFBO = m_fbo; 363 #if USE(OPENGL_ES_2) 364 if (m_attrs.depth) 365 glGenRenderbuffers(1, &m_depthBuffer); 366 if (m_attrs.stencil) 367 glGenRenderbuffers(1, &m_stencilBuffer); 368 #endif 369 if (m_attrs.stencil || m_attrs.depth) 370 glGenRenderbuffers(1, &m_depthStencilBuffer); 371 } 372 373 // ANGLE initialization. 374 ShBuiltInResources ANGLEResources; 375 ShInitBuiltInResources(&ANGLEResources); 376 377 getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs); 378 getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors); 379 getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors); 380 getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits); 381 getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); 382 getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits); 383 getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors); 384 385 // Always set to 1 for OpenGL ES. 386 ANGLEResources.MaxDrawBuffers = 1; 387 m_compiler.setResources(ANGLEResources); 404 if (renderStyle == RenderOffscreen) 405 m_private->createOffscreenBuffers(); 406 407 m_private->initializeANGLE(); 388 408 389 409 #if !USE(OPENGL_ES_2) … … 439 459 bool GraphicsContext3D::makeContextCurrent() 440 460 { 441 if (!m_private )461 if (!m_private || m_renderStyle == RenderToCurrentGLContext) 442 462 return false; 443 463 return m_private->makeCurrentIfNeeded();
Note: See TracChangeset
for help on using the changeset viewer.