Changeset 122116 in webkit
- Timestamp:
- Jul 9, 2012 11:00:11 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 added
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r122115 r122116 1 2012-07-09 Joshua Netterfield <jnetterfield@rim.com> 2 Make GC3D and E3D more maintainable for GLES platforms 3 https://bugs.webkit.org/show_bug.cgi?id=90567 4 5 Reviewed by Rob Buis. 6 7 This patch cleans up code for WebGL on OpenGLES platforms which use 8 GraphicsContext3DOpenGL* and Extensions3DOpenGL*. Although 9 GraphicsContext3DOpenGL was already split into GraphicsContext3DOpenGL, 10 GraphicsContext3DOpenGLCommon, and GraphicsContext3DOpenGLES, this patch 11 is an attempt to refactor this code in a way that will help BlackBerry and 12 other teams support WebGL on mobile platforms with as little use of 13 "#IF USE(OPENGL_ES_2)" in common code as possible. Also included is the 14 separation of Extensions3DOpenGL into Extensions3DOpenGLCommon, 15 Extensions3DOpenGL, and Extensions3DOpenGLES as well as the introduction 16 of OpenGLESShims. 17 18 This patch is created in large part by Jonathan Feldstein. 19 20 No new tests: no new behaviour. 21 22 * PlatformBlackBerry.cmake: Recognize BlackBerry as OPENGL ES, add new files to build 23 * Target.pri: Add new Extensions3DOpenGL* to WebGL builds 24 * platform/graphics/GraphicsContext3D.h: Add validateDepthStencil, make systemAllowsMultisamplingOnATICards a a member function. 25 (WebCore): 26 * platform/graphics/OpenGLESShims.h: Added. 27 * platform/graphics/opengl/Extensions3DOpenGL.cpp: Move code to Extensions3DOpenGLCommon where possible 28 (WebCore::Extensions3DOpenGL::Extensions3DOpenGL): Reflect that it is now inherits Extensions3DCommon 29 (WebCore::Extensions3DOpenGL::supportsExtension): Contains OpenGL specific code from supports 30 (WebCore): 31 (WebCore::Extensions3DOpenGL::getExtensions): Returns a list of extensions 32 * platform/graphics/opengl/Extensions3DOpenGL.h: Remove functions now in Extensions3DOpenGLCommon 33 (WebCore): 34 (Extensions3DOpenGL): 35 * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp: Added. 36 (WebCore): 37 (WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon): 38 (WebCore::Extensions3DOpenGLCommon::~Extensions3DOpenGLCommon): 39 (WebCore::Extensions3DOpenGLCommon::supports): 40 (WebCore::Extensions3DOpenGLCommon::ensureEnabled): 41 (WebCore::Extensions3DOpenGLCommon::isEnabled): 42 (WebCore::Extensions3DOpenGLCommon::getGraphicsResetStatusARB): 43 (WebCore::Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE): Existed before, but did nothing. Now does what is says it does. 44 (WebCore::Extensions3DOpenGLCommon::initializeAvailableExtensions): Moved from Extensions3DOpenGL::supports 45 * platform/graphics/opengl/Extensions3DOpenGLCommon.h: Copied from Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h. 46 (WebCore): 47 (Extensions3DOpenGLCommon): 48 * platform/graphics/opengl/Extensions3DOpenGLES.cpp: Added. 49 (WebCore): 50 (WebCore::Extensions3DOpenGLES::Extensions3DOpenGLES): 51 (WebCore::Extensions3DOpenGLES::~Extensions3DOpenGLES): 52 (WebCore::Extensions3DOpenGLES::framebufferTexture2DMultisampleIMG): 53 (WebCore::Extensions3DOpenGLES::renderbufferStorageMultisampleIMG): 54 (WebCore::Extensions3DOpenGLES::createVertexArrayOES): 55 (WebCore::Extensions3DOpenGLES::deleteVertexArrayOES): 56 (WebCore::Extensions3DOpenGLES::isVertexArrayOES): 57 (WebCore::Extensions3DOpenGLES::bindVertexArrayOES): 58 (WebCore::Extensions3DOpenGLES::supportsExtension): Contains OpenGLES specific code from supports 59 (WebCore::Extensions3DOpenGLES::getExtensions): 60 * platform/graphics/opengl/Extensions3DOpenGLES.h: Copied from Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h. 61 (WebCore): 62 (Extensions3DOpenGLES): 63 * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: 64 (WebCore::GraphicsContext3D::validateAttributes): 65 (WebCore): 66 (WebCore::GraphicsContext3D::renderbufferStorage): 67 (WebCore::GraphicsContext3D::texImage2D): 68 (WebCore::GraphicsContext3D::systemAllowsMultisamplingOnATICards): Now a member function. 69 (WebCore::GraphicsContext3D::getExtensions): 70 * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: 71 (WebCore::GraphicsContext3D::validateDepthStencil): 72 (WebCore::GraphicsContext3D::clear): 73 (WebCore::GraphicsContext3D::isTexture): 74 (WebCore): 75 (WebCore::GraphicsContext3D::lineWidth): 76 (WebCore::GraphicsContext3D::linkProgram): 77 (WebCore::GraphicsContext3D::pixelStorei): 78 (WebCore::GraphicsContext3D::polygonOffset): 79 (WebCore::GraphicsContext3D::readPixels): 80 (WebCore::GraphicsContext3D::deleteBuffer): 81 * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: 82 (WebCore::GraphicsContext3D::releaseShaderCompiler): 83 (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary): 84 (WebCore::GraphicsContext3D::validateAttributes): 85 (WebCore): 86 (WebCore::GraphicsContext3D::getExtensions): 87 (WebCore::GraphicsContext3D::systemAllowsMultisamplingOnATICards): Now a member function. 88 * platform/graphics/qt/GraphicsContext3DQt.cpp: 89 (WebCore): 90 (WebCore::GraphicsContext3D::releaseShaderCompiler): 91 1 92 2012-07-02 Ryosuke Niwa <rniwa@webkit.org> 2 93 -
trunk/Source/WebCore/GNUmakefile.list.am
r121900 r122116 6055 6055 Source/WebCore/platform/graphics/OpenGLShims.h \ 6056 6056 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \ 6057 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \ 6057 6058 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \ 6058 6059 Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \ -
trunk/Source/WebCore/PlatformBlackBerry.cmake
r121857 r122116 219 219 220 220 if (ENABLE_WEBGL) 221 ADD_DEFINITIONS (-DWTF_USE_OPENGL_ES_2=1) 221 222 LIST(APPEND WebCore_INCLUDE_DIRECTORIES 222 223 "${WEBCORE_DIR}/platform/graphics/gpu" … … 226 227 platform/graphics/blackberry/DrawingBufferBlackBerry.cpp 227 228 platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp 229 platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 230 platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp 231 platform/graphics/opengl/Extensions3DOpenGLCommon.cpp 232 platform/graphics/opengl/Extensions3DOpenGLES.cpp 233 platform/graphics/gpu/SharedGraphicsContext3D.cpp 228 234 ) 229 235 ENDIF () -
trunk/Source/WebCore/Target.pri
r122110 r122116 3957 3957 contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { 3958 3958 !contains(QT_CONFIG, opengles2) { 3959 SOURCES += platform/graphics/opengl/GraphicsContext3DOpenGL.cpp 3959 SOURCES += \ 3960 platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \ 3961 platform/graphics/opengl/Extensions3DOpenGL.cpp 3960 3962 } else { 3961 SOURCES += platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp 3963 SOURCES += \ 3964 platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp \ 3965 platform/graphics/opengl/Extensions3DOpenGLES.cpp 3962 3966 } 3963 3967 … … 3965 3969 3966 3970 SOURCES += \ 3967 platform/graphics/opengl/Extensions3DOpenGL .cpp \3971 platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \ 3968 3972 platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 3969 3973 -
trunk/Source/WebCore/WebCore.gypi
r122110 r122116 3808 3808 'platform/graphics/mac/WebTiledLayer.mm', 3809 3809 'platform/graphics/opengl/Extensions3DOpenGL.cpp', 3810 'platform/graphics/opengl/Extensions3DOpenGLCommon.cpp', 3810 3811 'platform/graphics/opengl/Extensions3DOpenGL.h', 3811 3812 'platform/graphics/opengl/GraphicsContext3DOpenGL.cpp', -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r122110 r122116 1192 1192 44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A28AAB12DFB8AC00AE923B /* MathMLElementFactory.h */; }; 1193 1193 44A28AAF12DFB8BF00AE923B /* MathMLNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A28AAE12DFB8BF00AE923B /* MathMLNames.h */; }; 1194 44DAB5B115A623580097C1E4 /* Extensions3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 44DAB5AF15A623580097C1E4 /* Extensions3DOpenGLCommon.cpp */; }; 1195 44DAB5B215A623580097C1E4 /* Extensions3DOpenGLCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 44DAB5B015A623580097C1E4 /* Extensions3DOpenGLCommon.h */; }; 1194 1196 45099C411370A7800058D513 /* IconURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45099C401370A7800058D513 /* IconURL.cpp */; }; 1195 1197 450CEBF015073BBE002BB149 /* LabelableElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 450CEBEE15073BBE002BB149 /* LabelableElement.cpp */; }; … … 8248 8250 44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; }; 8249 8251 44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; }; 8252 44DAB5AF15A623580097C1E4 /* Extensions3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Extensions3DOpenGLCommon.cpp; sourceTree = "<group>"; }; 8253 44DAB5B015A623580097C1E4 /* Extensions3DOpenGLCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Extensions3DOpenGLCommon.h; sourceTree = "<group>"; }; 8250 8254 45099C401370A7800058D513 /* IconURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IconURL.cpp; sourceTree = "<group>"; }; 8251 8255 450CEBEE15073BBE002BB149 /* LabelableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelableElement.cpp; sourceTree = "<group>"; }; … … 21647 21651 isa = PBXGroup; 21648 21652 children = ( 21653 44DAB5AF15A623580097C1E4 /* Extensions3DOpenGLCommon.cpp */, 21654 44DAB5B015A623580097C1E4 /* Extensions3DOpenGLCommon.h */, 21649 21655 6E67D2A41280E8A4008758F7 /* Extensions3DOpenGL.cpp */, 21650 21656 6E67D2A51280E8A4008758F7 /* Extensions3DOpenGL.h */, … … 25180 25186 A882DA231593848D000115ED /* CSSToStyleMap.h in Headers */, 25181 25187 1FAFBF1915A5FA7400083A20 /* UTIUtilities.h in Headers */, 25188 44DAB5B215A623580097C1E4 /* Extensions3DOpenGLCommon.h in Headers */, 25182 25189 ); 25183 25190 runOnlyForDeploymentPostprocessing = 0; … … 28235 28242 A882DA201593846A000115ED /* CSSToStyleMap.cpp in Sources */, 28236 28243 1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */, 28244 44DAB5B115A623580097C1E4 /* Extensions3DOpenGLCommon.cpp in Sources */, 28237 28245 ); 28238 28246 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r121159 r122116 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 … … 92 92 #endif 93 93 94 #if PLATFORM(BLACKBERRY)95 #include <GLES2/gl2.h>96 #endif97 98 94 namespace WebCore { 99 95 class DrawingBuffer; 100 96 class Extensions3D; 101 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) 97 #if USE(OPENGL_ES_2) 98 class Extensions3DOpenGLES; 99 #else 102 100 class Extensions3DOpenGL; 103 101 #endif … … 925 923 // could not be honored based on the capabilities of the OpenGL 926 924 // implementation. 925 void validateDepthStencil(const char* packedDepthStencilExtension); 927 926 void validateAttributes(); 928 927 … … 956 955 957 956 ANGLEWebKitBridge m_compiler; 958 957 #endif 958 959 #if PLATFORM(QT) && defined(QT_OPENGL_ES_2) 960 friend class Extensions3DQt; 961 OwnPtr<Extensions3DQt> m_extensions; 962 #elif PLATFORM(BLACKBERRY) 963 friend class Extensions3DOpenGLES; 964 OwnPtr<Extensions3DOpenGLES> m_extensions; 965 #elif !PLATFORM(CHROMIUM) 959 966 friend class Extensions3DOpenGL; 960 967 OwnPtr<Extensions3DOpenGL> m_extensions; 968 #endif 969 friend class Extensions3DOpenGLCommon; 961 970 962 971 Attributes m_attrs; 963 972 Vector<Vector<float> > m_vertexArray; 964 973 965 GC3Duint m_texture, m_compositorTexture; 974 GC3Duint m_texture; 975 #if !PLATFORM(BLACKBERRY) 976 GC3Duint m_compositorTexture; 977 #endif 966 978 GC3Duint m_fbo; 967 #if USE(OPENGL_ES_2) 979 980 #if !PLATFORM(BLACKBERRY) 968 981 GC3Duint m_depthBuffer; 969 982 GC3Duint m_stencilBuffer; … … 986 999 // Errors raised by synthesizeGLError(). 987 1000 ListHashSet<GC3Denum> m_syntheticErrors; 988 #endif989 1001 990 1002 friend class GraphicsContext3DPrivate; 991 1003 OwnPtr<GraphicsContext3DPrivate> m_private; 1004 1005 bool systemAllowsMultisamplingOnATICards() const; 992 1006 }; 993 1007 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r120826 r122116 34 34 #include "GraphicsContext3DPrivate.h" 35 35 #include "Image.h" 36 #include "NotImplemented.h" 36 37 #include "OpenGLShims.h" 37 38 #include "PlatformContextCairo.h" … … 145 146 } 146 147 ::glDeleteFramebuffersEXT(1, &m_fbo); 148 } 149 150 void GraphicsContext3D::releaseShaderCompiler() 151 { 152 notImplemented(); 147 153 } 148 154 -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp
r112141 r122116 57 57 } 58 58 59 void GraphicsContext3D::releaseShaderCompiler() 60 { 61 notImplemented(); 62 } 63 59 64 bool GraphicsContext3D::getImageData(Image* image, unsigned int format, unsigned int type, bool premultiplyAlpha, bool ignoreGammaAndColorProfile, Vector<uint8_t>& outputVector) 60 65 { -
trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
r118225 r122116 283 283 } 284 284 285 void GraphicsContext3D::releaseShaderCompiler() 286 { 287 notImplemented(); 288 } 289 285 290 } 286 291 -
trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
r121055 r122116 43 43 44 44 Extensions3DOpenGL::Extensions3DOpenGL(GraphicsContext3D* context) 45 : m_initializedAvailableExtensions(false) 45 : Extensions3DOpenGLCommon(context) 46 , m_initializedAvailableExtensions(false) 46 47 , m_context(context) 47 48 { … … 52 53 } 53 54 54 bool Extensions3DOpenGL::supports(const String& name)55 {56 // Note on support for BGRA:57 //58 // For OpenGL ES2.0, requires checking for59 // GL_EXT_texture_format_BGRA8888 and GL_EXT_read_format_bgra.60 // For desktop GL, BGRA has been supported since OpenGL 1.2.61 //62 // However, note that the GL ES2 extension requires the63 // internalFormat to glTexImage2D() be GL_BGRA, while desktop GL64 // will not accept GL_BGRA (must be GL_RGBA), so this must be65 // checked on each platform. Desktop GL offers neither66 // GL_EXT_texture_format_BGRA8888 or GL_EXT_read_format_bgra, so67 // treat them as unsupported here.68 if (!m_initializedAvailableExtensions) {69 String extensionsString(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS)));70 Vector<String> availableExtensions;71 extensionsString.split(" ", availableExtensions);72 for (size_t i = 0; i < availableExtensions.size(); ++i)73 m_availableExtensions.add(availableExtensions[i]);74 m_initializedAvailableExtensions = true;75 }76 77 // GL_ANGLE_framebuffer_blit and GL_ANGLE_framebuffer_multisample are "fake". They are implemented using other78 // extensions. In particular GL_EXT_framebuffer_blit and GL_EXT_framebuffer_multisample79 if (name == "GL_ANGLE_framebuffer_blit")80 return m_availableExtensions.contains("GL_EXT_framebuffer_blit");81 if (name == "GL_ANGLE_framebuffer_multisample")82 return m_availableExtensions.contains("GL_EXT_framebuffer_multisample");83 84 // Desktop GL always supports GL_OES_rgb8_rgba8.85 if (name == "GL_OES_rgb8_rgba8")86 return true;87 88 // If GL_ARB_texture_float is available then we report GL_OES_texture_float and89 // GL_OES_texture_half_float as available.90 if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float")91 return m_availableExtensions.contains("GL_ARB_texture_float");92 93 // GL_OES_vertex_array_object94 if (name == "GL_OES_vertex_array_object")95 return m_availableExtensions.contains("GL_APPLE_vertex_array_object");96 97 // Desktop GL always supports the standard derivative functions98 if (name == "GL_OES_standard_derivatives")99 return true;100 101 if (name == "GL_EXT_texture_filter_anisotropic")102 return m_availableExtensions.contains("GL_EXT_texture_filter_anisotropic");103 104 return m_availableExtensions.contains(name);105 }106 107 void Extensions3DOpenGL::ensureEnabled(const String& name)108 {109 #if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK)110 if (name == "GL_OES_standard_derivatives") {111 // Enable support in ANGLE (if not enabled already)112 ANGLEWebKitBridge& compiler = m_context->m_compiler;113 ShBuiltInResources ANGLEResources = compiler.getResources();114 if (!ANGLEResources.OES_standard_derivatives) {115 ANGLEResources.OES_standard_derivatives = 1;116 compiler.setResources(ANGLEResources);117 }118 }119 #else120 ASSERT_UNUSED(name, supports(name));121 #endif122 }123 124 bool Extensions3DOpenGL::isEnabled(const String& name)125 {126 #if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK)127 if (name == "GL_OES_standard_derivatives") {128 ANGLEWebKitBridge& compiler = m_context->m_compiler;129 return compiler.getResources().OES_standard_derivatives;130 }131 #endif132 return supports(name);133 }134 135 int Extensions3DOpenGL::getGraphicsResetStatusARB()136 {137 return GraphicsContext3D::NO_ERROR;138 }139 55 140 56 void Extensions3DOpenGL::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) … … 195 111 } 196 112 197 String Extensions3DOpenGL::getTranslatedShaderSourceANGLE(Platform3DObject shader)198 {199 UNUSED_PARAM(shader);200 return "";201 // FIXME: implement this function and add GL_ANGLE_translated_shader_source in supports().202 }203 204 113 void Extensions3DOpenGL::copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum) 205 114 { … … 208 117 } 209 118 119 bool Extensions3DOpenGL::supportsExtension(const String& name) 120 { 121 // GL_ANGLE_framebuffer_blit and GL_ANGLE_framebuffer_multisample are "fake". They are implemented using other 122 // extensions. In particular GL_EXT_framebuffer_blit and GL_EXT_framebuffer_multisample 123 if (name == "GL_ANGLE_framebuffer_blit") 124 return m_availableExtensions.contains("GL_EXT_framebuffer_blit"); 125 if (name == "GL_ANGLE_framebuffer_multisample") 126 return m_availableExtensions.contains("GL_EXT_framebuffer_multisample"); 127 128 // Desktop GL always supports GL_OES_rgb8_rgba8. 129 if (name == "GL_OES_rgb8_rgba8") 130 return true; 131 132 // If GL_ARB_texture_float is available then we report GL_OES_texture_float and 133 // GL_OES_texture_half_float as available. 134 if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float") 135 return m_availableExtensions.contains("GL_ARB_texture_float"); 136 137 // GL_OES_vertex_array_object 138 if (name == "GL_OES_vertex_array_object") 139 return m_availableExtensions.contains("GL_APPLE_vertex_array_object"); 140 141 // Desktop GL always supports the standard derivative functions 142 if (name == "GL_OES_standard_derivatives") 143 return true; 144 145 if (name == "GL_EXT_texture_filter_anisotropic") 146 return m_availableExtensions.contains("GL_EXT_texture_filter_anisotropic"); 147 148 return m_availableExtensions.contains(name); 149 } 150 151 String Extensions3DOpenGL::getExtensions() 152 { 153 return String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS))); 154 } 155 210 156 } // namespace WebCore 211 157 -
trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
r121055 r122116 27 27 #define Extensions3DOpenGL_h 28 28 29 #include "Extensions3D .h"29 #include "Extensions3DOpenGLCommon.h" 30 30 31 31 #include "GraphicsContext3D.h" … … 35 35 namespace WebCore { 36 36 37 class Extensions3DOpenGL : public Extensions3D {37 class Extensions3DOpenGL : public Extensions3DOpenGLCommon { 38 38 public: 39 39 virtual ~Extensions3DOpenGL(); 40 40 41 41 // Extensions3D methods. 42 virtual bool supports(const String&);43 virtual void ensureEnabled(const String&);44 virtual bool isEnabled(const String&);45 virtual int getGraphicsResetStatusARB();46 42 virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter); 47 43 virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height); … … 51 47 virtual GC3Dboolean isVertexArrayOES(Platform3DObject); 52 48 virtual void bindVertexArrayOES(Platform3DObject); 53 virtual String getTranslatedShaderSourceANGLE(Platform3DObject);54 49 virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum); 55 50 56 pr ivate:51 protected: 57 52 // This class only needs to be instantiated by GraphicsContext3D implementations. 58 53 friend class GraphicsContext3D; 59 54 Extensions3DOpenGL(GraphicsContext3D*); 60 55 56 virtual bool supportsExtension(const WTF::String&); 57 virtual String getExtensions(); 58 59 private: 61 60 bool m_initializedAvailableExtensions; 62 61 HashSet<String> m_availableExtensions; -
trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h
r122115 r122116 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 24 25 */ 25 26 26 #ifndef Extensions3DOpenGL _h27 #define Extensions3DOpenGL _h27 #ifndef Extensions3DOpenGLCommon_h 28 #define Extensions3DOpenGLCommon_h 28 29 29 30 #include "Extensions3D.h" … … 35 36 namespace WebCore { 36 37 37 class Extensions3DOpenGL : public Extensions3D {38 class Extensions3DOpenGLCommon : public Extensions3D { 38 39 public: 39 virtual ~Extensions3DOpenGL ();40 virtual ~Extensions3DOpenGLCommon(); 40 41 41 42 // Extensions3D methods. … … 44 45 virtual bool isEnabled(const String&); 45 46 virtual int getGraphicsResetStatusARB(); 46 virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter); 47 virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height); 48 49 virtual Platform3DObject createVertexArrayOES(); 50 virtual void deleteVertexArrayOES(Platform3DObject); 51 virtual GC3Dboolean isVertexArrayOES(Platform3DObject); 52 virtual void bindVertexArrayOES(Platform3DObject); 47 48 virtual Platform3DObject createVertexArrayOES() = 0; 49 virtual void deleteVertexArrayOES(Platform3DObject) = 0; 50 virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0; 51 virtual void bindVertexArrayOES(Platform3DObject) = 0; 52 53 53 virtual String getTranslatedShaderSourceANGLE(Platform3DObject); 54 virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum); 54 55 protected: 56 Extensions3DOpenGLCommon(GraphicsContext3D*); 57 58 virtual bool supportsExtension(const String&) = 0; 59 virtual String getExtensions() = 0; 55 60 56 61 private: 57 // This class only needs to be instantiated by GraphicsContext3D implementations. 58 friend class GraphicsContext3D; 59 Extensions3DOpenGL(GraphicsContext3D*); 60 62 virtual void initializeAvailableExtensions(); 61 63 bool m_initializedAvailableExtensions; 62 64 HashSet<String> m_availableExtensions; 63 65 64 66 // Weak pointer back to GraphicsContext3D 65 67 GraphicsContext3D* m_context; … … 68 70 } // namespace WebCore 69 71 70 #endif // Extensions3DOpenGL _h72 #endif // Extensions3DOpenGLCommon_h -
trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h
r122115 r122116 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 24 25 */ 25 26 26 #ifndef Extensions3DOpenGL _h27 #define Extensions3DOpenGL _h27 #ifndef Extensions3DOpenGLES_h 28 #define Extensions3DOpenGLES_h 28 29 29 #include "Extensions3D .h"30 #include "Extensions3DOpenGLCommon.h" 30 31 31 #include "GraphicsContext3D.h" 32 #include <wtf/HashSet.h> 33 #include <wtf/text/StringHash.h> 32 #include <GLES2/gl2.h> 33 #include <GLES2/gl2ext.h> 34 34 35 35 namespace WebCore { 36 36 37 class Extensions3DOpenGL : public Extensions3D{37 class Extensions3DOpenGLES : public Extensions3DOpenGLCommon { 38 38 public: 39 virtual ~Extensions3DOpenGL ();39 virtual ~Extensions3DOpenGLES(); 40 40 41 // Extensions3D methods. 42 virtual bool supports(const String&); 43 virtual void ensureEnabled(const String&); 44 virtual bool isEnabled(const String&); 45 virtual int getGraphicsResetStatusARB(); 46 virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter); 47 virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height); 48 41 virtual void framebufferTexture2DMultisampleIMG(unsigned long target, unsigned long attachment, unsigned long textarget, unsigned int texture, int level, unsigned long samples); 42 virtual void renderbufferStorageMultisampleIMG(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height); 43 49 44 virtual Platform3DObject createVertexArrayOES(); 50 45 virtual void deleteVertexArrayOES(Platform3DObject); 51 46 virtual GC3Dboolean isVertexArrayOES(Platform3DObject); 52 47 virtual void bindVertexArrayOES(Platform3DObject); 53 virtual String getTranslatedShaderSourceANGLE(Platform3DObject);54 virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum);55 48 56 pr ivate:49 protected: 57 50 // This class only needs to be instantiated by GraphicsContext3D implementations. 58 51 friend class GraphicsContext3D; 59 Extensions3DOpenGL (GraphicsContext3D*);52 Extensions3DOpenGLES(GraphicsContext3D*); 60 53 61 bool m_initializedAvailableExtensions; 62 HashSet<String> m_availableExtensions; 63 64 // Weak pointer back to GraphicsContext3D 65 GraphicsContext3D* m_context; 54 virtual bool supportsExtension(const String&); 55 virtual String getExtensions(); 56 57 bool m_supportsOESvertexArrayObject; 58 bool m_supportsIMGMultisampledRenderToTexture; 59 60 PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC m_glFramebufferTexture2DMultisampleIMG; 61 PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC m_glRenderbufferStorageMultisampleIMG; 62 PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES; 63 PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES; 64 PFNGLGENVERTEXARRAYSOESPROC m_glGenVertexArraysOES; 65 PFNGLISVERTEXARRAYOESPROC m_glIsVertexArrayOES; 66 66 }; 67 67 68 68 } // namespace WebCore 69 69 70 #endif // Extensions3DOpenGL _h70 #endif // Extensions3DOpenGLES_h -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
r119552 r122116 1 1 /* 2 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 35 36 #include "NotImplemented.h" 36 37 38 #include <algorithm> 39 #include <cstring> 40 #include <wtf/UnusedParam.h> 41 #include <wtf/text/CString.h> 42 37 43 #if PLATFORM(MAC) 38 44 #include <OpenGL/gl.h> … … 46 52 { 47 53 ::glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels); 54 } 55 56 void GraphicsContext3D::validateAttributes() 57 { 58 Extensions3D* extensions = getExtensions(); 59 if (m_attrs.stencil) { 60 const char* packedDepthStencilExtension = isGLES2Compliant() ? "GL_OES_packed_depth_stencil" : "GL_EXT_packed_depth_stencil"; 61 if (extensions->supports(packedDepthStencilExtension)) { 62 extensions->ensureEnabled(packedDepthStencilExtension); 63 // Force depth if stencil is true. 64 m_attrs.depth = true; 65 } else 66 m_attrs.stencil = false; 67 } 68 if (m_attrs.antialias) { 69 bool isValidVendor = true; 70 // Currently in Mac we only turn on antialias if vendor is NVIDIA, 71 // or if ATI and on 10.7.2 and above. 72 const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR)); 73 if (!vendor || (!std::strstr(vendor, "NVIDIA") && !(std::strstr(vendor, "ATI") && systemAllowsMultisamplingOnATICards()))) 74 isValidVendor = false; 75 if (!isValidVendor || !extensions->supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant()) 76 m_attrs.antialias = false; 77 else 78 extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample"); 79 } 48 80 } 49 81 … … 257 289 } 258 290 291 bool GraphicsContext3D::systemAllowsMultisamplingOnATICards() const 292 { 293 #if PLATFORM(MAC) 294 #if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) 295 return true; 296 #else 297 ASSERT(isMainThread()); 298 static SInt32 version; 299 if (!version) { 300 if (Gestalt(gestaltSystemVersion, &version) != noErr) 301 return false; 302 } 303 // See https://bugs.webkit.org/show_bug.cgi?id=77922 for more details 304 return version >= 0x1072; 305 #endif // SNOW_LEOPARD and LION 306 #else 307 return false; 308 #endif // PLATFORM(MAC) 309 } 310 311 Extensions3D* GraphicsContext3D::getExtensions() 312 { 313 if (!m_extensions) 314 m_extensions = adoptPtr(new Extensions3DOpenGL(this)); 315 return m_extensions.get(); 316 } 317 259 318 } 260 319 -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
r119552 r122116 1 1 /* 2 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 4 * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com> 5 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 4 6 * 5 7 * Redistribution and use in source and binary forms, with or without … … 31 33 #include "GraphicsContext3D.h" 32 34 35 #include "CanvasRenderingContext.h" 36 #if USE(OPENGL_ES_2) 37 #include "Extensions3DOpenGLES.h" 38 #else 33 39 #include "Extensions3DOpenGL.h" 40 #endif 34 41 #include "GraphicsContext.h" 35 42 #include "ImageBuffer.h" … … 50 57 #include <wtf/text/CString.h> 51 58 52 #if PLATFORM(MAC) 59 #if USE(OPENGL_ES_2) 60 #include "OpenGLESShims.h" 61 #elif PLATFORM(MAC) 53 62 #include <OpenGL/gl.h> 54 63 #elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) … … 56 65 #endif 57 66 67 #if PLATFORM(BLACKBERRY) 68 #include <BlackBerryPlatformLog.h> 69 #endif 70 58 71 namespace WebCore { 59 72 60 static bool systemAllowsMultisamplingOnATICards() 61 { 62 #if PLATFORM(MAC) 63 #if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) 64 return true; 65 #else 66 ASSERT(isMainThread()); 67 static SInt32 version; 68 if (!version) { 69 if (Gestalt(gestaltSystemVersion, &version) != noErr) 70 return false; 71 } 72 // See https://bugs.webkit.org/show_bug.cgi?id=77922 for more details 73 return version >= 0x1072; 74 #endif // SNOW_LEOPARD and LION 75 #else 76 return false; 77 #endif // PLATFORM(MAC) 78 } 79 80 void GraphicsContext3D::validateAttributes() 73 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension) 81 74 { 82 75 Extensions3D* extensions = getExtensions(); 83 76 if (m_attrs.stencil) { 84 const char* packedDepthStencilExtension = isGLES2Compliant() ? "GL_OES_packed_depth_stencil" : "GL_EXT_packed_depth_stencil";85 77 if (extensions->supports(packedDepthStencilExtension)) { 86 78 extensions->ensureEnabled(packedDepthStencilExtension); … … 440 432 makeContextCurrent(); 441 433 442 int GLshaderType; 443 ANGLEShaderType shaderType; 444 445 glGetShaderiv(shader, SHADER_TYPE, &GLshaderType); 446 447 if (GLshaderType == VERTEX_SHADER) 448 shaderType = SHADER_TYPE_VERTEX; 449 else if (GLshaderType == FRAGMENT_SHADER) 450 shaderType = SHADER_TYPE_FRAGMENT; 451 else 452 return; // Invalid shader type. 453 454 HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); 455 456 if (result == m_shaderSourceMap.end()) 434 String translatedShaderSource = m_extensions->getTranslatedShaderSourceANGLE(shader); 435 436 if (!translatedShaderSource.length()) 457 437 return; 458 459 ShaderSourceEntry& entry = result->second;460 461 String translatedShaderSource;462 String shaderInfoLog;463 464 bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);465 466 entry.log = shaderInfoLog;467 entry.isValid = isValid;468 469 if (!isValid)470 return; // Shader didn't validate, don't move forward with compiling translated source.471 438 472 439 int translatedShaderLength = translatedShaderSource.length(); … … 802 769 ::glFlush(); 803 770 } 771 // Currently only format=RGBA, type=UNSIGNED_BYTE is supported by the specification: http://www.khronos.org/registry/webgl/specs/latest/ 772 // If this ever changes, this code will need to be updated. 773 774 // Calculate the strides of our data and canvas 775 unsigned int formatSize = 4; // RGBA UNSIGNED_BYTE 776 unsigned int dataStride = width * formatSize; 777 unsigned int canvasStride = m_currentWidth * formatSize; 778 779 // If we are using a pack alignment of 8, then we need to align our strides to 8 byte boundaries 780 // See: http://en.wikipedia.org/wiki/Data_structure_alignment (computing padding) 781 int packAlignment; 782 glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment); 783 if (8 == packAlignment) { 784 dataStride = (dataStride + 7) & ~7; 785 canvasStride = (canvasStride + 7) & ~7; 786 } 787 788 unsigned char* canvasData = new unsigned char[canvasStride * m_currentHeight]; 789 ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, format, type, canvasData); 790 791 // If we failed to read our canvas data due to a GL error, don't continue 792 int error = glGetError(); 793 if (GL_NO_ERROR != error) { 794 synthesizeGLError(error); 795 return; 796 } 797 798 // Clear our data in case some of it lies outside the bounds of our canvas 799 // TODO: don't do this if all of the data lies inside the bounds of the canvas 800 memset(data, 0, dataStride * height); 801 802 // Calculate the intersection of our canvas and data bounds 803 IntRect dataRect(x, y, width, height); 804 IntRect canvasRect(0, 0, m_currentWidth, m_currentHeight); 805 IntRect nonZeroDataRect = intersection(dataRect, canvasRect); 806 807 unsigned int xDataOffset = x < 0 ? -x * formatSize : 0; 808 unsigned int yDataOffset = y < 0 ? -y * dataStride : 0; 809 unsigned int xCanvasOffset = nonZeroDataRect.x() * formatSize; 810 unsigned int yCanvasOffset = nonZeroDataRect.y() * canvasStride; 811 unsigned char* dst = static_cast<unsigned char*>(data) + xDataOffset + yDataOffset; 812 unsigned char* src = canvasData + xCanvasOffset + yCanvasOffset; 813 for (int row = 0; row < nonZeroDataRect.height(); row++) { 814 memcpy(dst, src, nonZeroDataRect.width() * formatSize); 815 dst += dataStride; 816 src += canvasStride; 817 } 818 819 delete [] canvasData; 804 820 ::glReadPixels(x, y, width, height, format, type, data); 821 805 822 if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) 806 823 ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); 807 }808 809 void GraphicsContext3D::releaseShaderCompiler()810 {811 // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants.812 makeContextCurrent();813 notImplemented();814 824 } 815 825 … … 1387 1397 } 1388 1398 1389 Extensions3D* GraphicsContext3D::getExtensions()1390 {1391 if (!m_extensions)1392 m_extensions = adoptPtr(new Extensions3DOpenGL(this));1393 return m_extensions.get();1394 }1395 1396 1399 } 1397 1400 -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
r119552 r122116 1 1 /* 2 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 4 * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com> 5 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 4 6 * 5 7 * Redistribution and use in source and binary forms, with or without … … 30 32 31 33 #include "GraphicsContext3D.h" 32 33 #include "Extensions3DOpenGL.h" 34 #include "Extensions3DOpenGLES.h" 34 35 #include "IntRect.h" 35 36 #include "IntSize.h" 37 #include "LayerWebKitThread.h" 36 38 #include "NotImplemented.h" 37 38 #if PLATFORM(GTK) || PLATFORM(QT) 39 #include "OpenGLShims.h" 40 #endif 39 #include "OpenGLESShims.h" 41 40 42 41 namespace WebCore { 43 42 43 void GraphicsContext3D::releaseShaderCompiler() 44 { 45 makeContextCurrent(); 46 ::glReleaseShaderCompiler(); 47 } 48 44 49 void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels) 45 50 { 46 const int totalBytes = m_currentWidth * m_currentHeight * 4;47 51 ::glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 48 for (int i = 0; i < totalBytes; i += 4) 49 std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA. 50 } 51 52 bool GraphicsContext3D::reshapeFBOs(const IntSize& size) 53 { 54 const int width = size.width(); 55 const int height = size.height(); 56 GLuint colorFormat = 0, pixelDataType = 0; 57 if (m_attrs.alpha) { 58 m_internalColorFormat = GL_RGBA; 59 colorFormat = GL_RGBA; 60 pixelDataType = GL_UNSIGNED_BYTE; 61 } else { 62 m_internalColorFormat = GL_RGB; 63 colorFormat = GL_RGB; 64 pixelDataType = GL_UNSIGNED_SHORT_5_6_5; 52 int totalBytes = width * height * 4; 53 if (isGLES2Compliant()) { 54 for (int i = 0; i < totalBytes; i += 4) 55 std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA. 65 56 } 66 67 // We don't allow the logic where stencil is required and depth is not.68 // See GraphicsContext3D::validateAttributes.69 bool supportPackedDepthStencilBuffer = (m_attrs.stencil || m_attrs.depth) && getExtensions()->supports("GL_OES_packed_depth_stencil");70 71 // Resize regular FBO.72 bool mustRestoreFBO = false;73 if (m_boundFBO != m_fbo) {74 mustRestoreFBO = true;75 ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);76 }77 78 ::glBindTexture(GL_TEXTURE_2D, m_texture);79 ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0);80 ::glFramebufferTexture2DEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);81 82 ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture);83 ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);84 ::glBindTexture(GL_TEXTURE_2D, 0);85 86 // We don't support antialiasing yet. See GraphicsContext3D::validateAttributes.87 ASSERT(!m_attrs.antialias);88 89 if (m_attrs.stencil || m_attrs.depth) {90 // Use a 24 bit depth buffer where we know we have it.91 if (supportPackedDepthStencilBuffer) {92 ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffer);93 ::glTexImage2D(GL_TEXTURE_2D, 0, GraphicsContext3D::DEPTH_STENCIL, width, height, 0, GraphicsContext3D::DEPTH_STENCIL, GraphicsContext3D::UNSIGNED_INT_24_8, 0);94 if (m_attrs.stencil)95 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);96 if (m_attrs.depth)97 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);98 ::glBindTexture(GL_TEXTURE_2D, 0);99 } else {100 if (m_attrs.stencil) {101 ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);102 ::glRenderbufferStorageEXT(GraphicsContext3D::RENDERBUFFER, GL_STENCIL_INDEX8, width, height);103 ::glFramebufferRenderbufferEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);104 }105 if (m_attrs.depth) {106 ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, m_depthBuffer);107 ::glRenderbufferStorageEXT(GraphicsContext3D::RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);108 ::glFramebufferRenderbufferEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer);109 }110 ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, 0);111 }112 }113 if (glCheckFramebufferStatusEXT(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {114 // FIXME: cleanup115 notImplemented();116 }117 118 return mustRestoreFBO;119 57 } 120 58 … … 157 95 } 158 96 97 void GraphicsContext3D::validateAttributes() 98 { 99 validateDepthStencil("GL_OES_packed_depth_stencil"); 100 101 if (m_attrs.antialias) { 102 Extensions3D* extensions = getExtensions(); 103 if (!extensions->supports("GL_IMG_multisampled_render_to_texture")) 104 m_attrs.antialias = false; 105 } 106 } 107 159 108 void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar) 160 109 { … … 169 118 } 170 119 171 } // namespace WebCore 120 121 Extensions3D* GraphicsContext3D::getExtensions() 122 { 123 if (!m_extensions) 124 m_extensions = adoptPtr(new Extensions3DOpenGLES(this)); 125 return m_extensions.get(); 126 } 127 128 bool GraphicsContext3D::systemAllowsMultisamplingOnATICards() const 129 { 130 return false; // not applicable 131 } 132 133 } 172 134 173 135 #endif // ENABLE(WEBGL) -
trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
r122037 r122116 98 98 #endif 99 99 } 100 101 #if !USE(OPENGL_ES_2) 102 void GraphicsContext3D::releaseShaderCompiler() 103 { 104 notImplemented(); 105 } 106 #endif 100 107 101 108 GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow)
Note: See TracChangeset
for help on using the changeset viewer.