| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ | 5 #ifndef WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ |
| 6 #define WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ | 6 #define WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "third_party/angle/include/GLSLANG/ShaderLang.h" | 13 #include "third_party/angle/include/GLSLANG/ShaderLang.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.
h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.
h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 16 | 16 |
| 17 #if !defined(OS_MACOSX) | 17 #if !defined(OS_MACOSX) |
| 18 #define FLIP_FRAMEBUFFER_VERTICALLY | 18 #define FLIP_FRAMEBUFFER_VERTICALLY |
| 19 #endif | 19 #endif |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class GLContext; | 21 class GLContext; |
| 22 } | 22 } |
| 23 | 23 |
| 24 #if defined(USE_WGC3D_TYPES) | |
| 25 using WebKit::WGC3Dchar; | |
| 26 using WebKit::WGC3Denum; | |
| 27 using WebKit::WGC3Dboolean; | |
| 28 using WebKit::WGC3Dbitfield; | |
| 29 using WebKit::WGC3Dint; | |
| 30 using WebKit::WGC3Dsizei; | |
| 31 using WebKit::WGC3Duint; | |
| 32 using WebKit::WGC3Dfloat; | |
| 33 using WebKit::WGC3Dclampf; | |
| 34 using WebKit::WGC3Dintptr; | |
| 35 using WebKit::WGC3Dsizeiptr; | |
| 36 #endif | |
| 37 | |
| 38 using WebKit::WebGLId; | |
| 39 | |
| 40 using WebKit::WebString; | |
| 41 using WebKit::WebView; | |
| 42 | |
| 43 using WebKit::WebGraphicsContext3D; | |
| 44 | |
| 45 namespace webkit { | 24 namespace webkit { |
| 46 namespace gpu { | 25 namespace gpu { |
| 47 | 26 |
| 48 // The default implementation of WebGL. In Chromium, using this class | 27 // The default implementation of WebGL. In Chromium, using this class |
| 49 // requires the sandbox to be disabled, which is strongly discouraged. | 28 // requires the sandbox to be disabled, which is strongly discouraged. |
| 50 // It is provided for support of test_shell and any Chromium ports | 29 // It is provided for support of test_shell and any Chromium ports |
| 51 // where an in-renderer WebGL implementation would be helpful. | 30 // where an in-renderer WebGL implementation would be helpful. |
| 52 | 31 |
| 53 #if defined(USE_WGC3D_TYPES) | |
| 54 | |
| 55 class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D { | |
| 56 public: | |
| 57 WebGraphicsContext3DInProcessImpl(); | |
| 58 virtual ~WebGraphicsContext3DInProcessImpl(); | |
| 59 | |
| 60 //---------------------------------------------------------------------- | |
| 61 // WebGraphicsContext3D methods | |
| 62 virtual bool initialize( | |
| 63 WebGraphicsContext3D::Attributes attributes, WebView*, bool); | |
| 64 virtual bool makeContextCurrent(); | |
| 65 | |
| 66 virtual int width(); | |
| 67 virtual int height(); | |
| 68 | |
| 69 virtual bool isGLES2Compliant(); | |
| 70 | |
| 71 virtual void reshape(int width, int height); | |
| 72 | |
| 73 virtual bool readBackFramebuffer(unsigned char* pixels, size_t bufferSize); | |
| 74 | |
| 75 virtual WebGLId getPlatformTextureId(); | |
| 76 virtual void prepareTexture(); | |
| 77 | |
| 78 virtual void synthesizeGLError(WGC3Denum error); | |
| 79 virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target, WGC3Dintptr offset, | |
| 80 WGC3Dsizeiptr size, WGC3Denum access); | |
| 81 virtual void unmapBufferSubDataCHROMIUM(const void*); | |
| 82 virtual void* mapTexSubImage2DCHROMIUM( | |
| 83 WGC3Denum target, | |
| 84 WGC3Dint level, | |
| 85 WGC3Dint xoffset, | |
| 86 WGC3Dint yoffset, | |
| 87 WGC3Dsizei width, | |
| 88 WGC3Dsizei height, | |
| 89 WGC3Denum format, | |
| 90 WGC3Denum type, | |
| 91 WGC3Denum access); | |
| 92 virtual void unmapTexSubImage2DCHROMIUM(const void*); | |
| 93 virtual void copyTextureToParentTextureCHROMIUM( | |
| 94 WebGLId texture, WebGLId parentTexture); | |
| 95 | |
| 96 virtual WebString getRequestableExtensionsCHROMIUM(); | |
| 97 virtual void requestExtensionCHROMIUM(const char*); | |
| 98 | |
| 99 virtual void blitFramebufferCHROMIUM( | |
| 100 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, | |
| 101 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, | |
| 102 WGC3Dbitfield mask, WGC3Denum filter); | |
| 103 virtual void renderbufferStorageMultisampleCHROMIUM( | |
| 104 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, | |
| 105 WGC3Dsizei width, WGC3Dsizei height); | |
| 106 | |
| 107 virtual void activeTexture(WGC3Denum texture); | |
| 108 virtual void attachShader(WebGLId program, WebGLId shader); | |
| 109 virtual void bindAttribLocation( | |
| 110 WebGLId program, WGC3Duint index, const WGC3Dchar* name); | |
| 111 virtual void bindBuffer(WGC3Denum target, WebGLId buffer); | |
| 112 virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer); | |
| 113 virtual void bindRenderbuffer( | |
| 114 WGC3Denum target, WebGLId renderbuffer); | |
| 115 virtual void bindTexture(WGC3Denum target, WebGLId texture); | |
| 116 virtual void blendColor( | |
| 117 WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha); | |
| 118 virtual void blendEquation(WGC3Denum mode); | |
| 119 virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha); | |
| 120 virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor); | |
| 121 virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB, | |
| 122 WGC3Denum srcAlpha, WGC3Denum dstAlpha); | |
| 123 | |
| 124 virtual void bufferData( | |
| 125 WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage); | |
| 126 virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, | |
| 127 WGC3Dsizeiptr size, const void* data); | |
| 128 | |
| 129 virtual WGC3Denum checkFramebufferStatus(WGC3Denum target); | |
| 130 virtual void clear(WGC3Dbitfield mask); | |
| 131 virtual void clearColor( | |
| 132 WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha); | |
| 133 virtual void clearDepth(WGC3Dclampf depth); | |
| 134 virtual void clearStencil(WGC3Dint s); | |
| 135 virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, | |
| 136 WGC3Dboolean blue, WGC3Dboolean alpha); | |
| 137 virtual void compileShader(WebGLId shader); | |
| 138 | |
| 139 virtual void copyTexImage2D( | |
| 140 WGC3Denum target, | |
| 141 WGC3Dint level, | |
| 142 WGC3Denum internalformat, | |
| 143 WGC3Dint x, | |
| 144 WGC3Dint y, | |
| 145 WGC3Dsizei width, | |
| 146 WGC3Dsizei height, | |
| 147 WGC3Dint border); | |
| 148 virtual void copyTexSubImage2D( | |
| 149 WGC3Denum target, | |
| 150 WGC3Dint level, | |
| 151 WGC3Dint xoffset, | |
| 152 WGC3Dint yoffset, | |
| 153 WGC3Dint x, | |
| 154 WGC3Dint y, | |
| 155 WGC3Dsizei width, | |
| 156 WGC3Dsizei height); | |
| 157 virtual void cullFace(WGC3Denum mode); | |
| 158 virtual void depthFunc(WGC3Denum func); | |
| 159 virtual void depthMask(WGC3Dboolean flag); | |
| 160 virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar); | |
| 161 virtual void detachShader(WebGLId program, WebGLId shader); | |
| 162 virtual void disable(WGC3Denum cap); | |
| 163 virtual void disableVertexAttribArray(WGC3Duint index); | |
| 164 virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count); | |
| 165 virtual void drawElements( | |
| 166 WGC3Denum mode, | |
| 167 WGC3Dsizei count, | |
| 168 WGC3Denum type, | |
| 169 WGC3Dintptr offset); | |
| 170 | |
| 171 virtual void enable(WGC3Denum cap); | |
| 172 virtual void enableVertexAttribArray(WGC3Duint index); | |
| 173 virtual void finish(); | |
| 174 virtual void flush(); | |
| 175 virtual void framebufferRenderbuffer( | |
| 176 WGC3Denum target, | |
| 177 WGC3Denum attachment, | |
| 178 WGC3Denum renderbuffertarget, | |
| 179 WebGLId renderbuffer); | |
| 180 virtual void framebufferTexture2D( | |
| 181 WGC3Denum target, | |
| 182 WGC3Denum attachment, | |
| 183 WGC3Denum textarget, | |
| 184 WebGLId texture, | |
| 185 WGC3Dint level); | |
| 186 virtual void frontFace(WGC3Denum mode); | |
| 187 virtual void generateMipmap(WGC3Denum target); | |
| 188 | |
| 189 virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo&); | |
| 190 virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo&); | |
| 191 | |
| 192 virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, | |
| 193 WGC3Dsizei* count, WebGLId* shaders); | |
| 194 | |
| 195 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name); | |
| 196 | |
| 197 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value); | |
| 198 | |
| 199 virtual void getBufferParameteriv( | |
| 200 WGC3Denum target, WGC3Denum pname, WGC3Dint* value); | |
| 201 | |
| 202 virtual Attributes getContextAttributes(); | |
| 203 | |
| 204 virtual WGC3Denum getError(); | |
| 205 | |
| 206 virtual bool isContextLost(); | |
| 207 | |
| 208 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value); | |
| 209 | |
| 210 virtual void getFramebufferAttachmentParameteriv( | |
| 211 WGC3Denum target, | |
| 212 WGC3Denum attachment, | |
| 213 WGC3Denum pname, | |
| 214 WGC3Dint* value); | |
| 215 | |
| 216 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value); | |
| 217 | |
| 218 virtual void getProgramiv( | |
| 219 WebGLId program, WGC3Denum pname, WGC3Dint* value); | |
| 220 | |
| 221 virtual WebString getProgramInfoLog(WebGLId program); | |
| 222 | |
| 223 virtual void getRenderbufferParameteriv( | |
| 224 WGC3Denum target, WGC3Denum pname, WGC3Dint* value); | |
| 225 | |
| 226 virtual void getShaderiv( | |
| 227 WebGLId shader, WGC3Denum pname, WGC3Dint* value); | |
| 228 | |
| 229 virtual WebString getShaderInfoLog(WebGLId shader); | |
| 230 | |
| 231 // TBD | |
| 232 // void glGetShaderPrecisionFormat( | |
| 233 // GLenum shadertype, GLenum precisiontype, | |
| 234 // GLint* range, GLint* precision); | |
| 235 | |
| 236 virtual WebString getShaderSource(WebGLId shader); | |
| 237 virtual WebString getString(WGC3Denum name); | |
| 238 | |
| 239 virtual void getTexParameterfv( | |
| 240 WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value); | |
| 241 virtual void getTexParameteriv( | |
| 242 WGC3Denum target, WGC3Denum pname, WGC3Dint* value); | |
| 243 | |
| 244 virtual void getUniformfv( | |
| 245 WebGLId program, WGC3Dint location, WGC3Dfloat* value); | |
| 246 virtual void getUniformiv( | |
| 247 WebGLId program, WGC3Dint location, WGC3Dint* value); | |
| 248 | |
| 249 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name); | |
| 250 | |
| 251 virtual void getVertexAttribfv( | |
| 252 WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value); | |
| 253 virtual void getVertexAttribiv( | |
| 254 WGC3Duint index, WGC3Denum pname, WGC3Dint* value); | |
| 255 | |
| 256 virtual WGC3Dsizeiptr getVertexAttribOffset( | |
| 257 WGC3Duint index, WGC3Denum pname); | |
| 258 | |
| 259 virtual void hint(WGC3Denum target, WGC3Denum mode); | |
| 260 virtual WGC3Dboolean isBuffer(WebGLId buffer); | |
| 261 virtual WGC3Dboolean isEnabled(WGC3Denum cap); | |
| 262 virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer); | |
| 263 virtual WGC3Dboolean isProgram(WebGLId program); | |
| 264 virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer); | |
| 265 virtual WGC3Dboolean isShader(WebGLId shader); | |
| 266 virtual WGC3Dboolean isTexture(WebGLId texture); | |
| 267 virtual void lineWidth(WGC3Dfloat width); | |
| 268 virtual void linkProgram(WebGLId program); | |
| 269 virtual void pixelStorei(WGC3Denum pname, WGC3Dint param); | |
| 270 virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units); | |
| 271 | |
| 272 virtual void readPixels( | |
| 273 WGC3Dint x, WGC3Dint y, | |
| 274 WGC3Dsizei width, WGC3Dsizei height, | |
| 275 WGC3Denum format, | |
| 276 WGC3Denum type, | |
| 277 void* pixels); | |
| 278 | |
| 279 virtual void releaseShaderCompiler(); | |
| 280 virtual void renderbufferStorage( | |
| 281 WGC3Denum target, | |
| 282 WGC3Denum internalformat, | |
| 283 WGC3Dsizei width, | |
| 284 WGC3Dsizei height); | |
| 285 virtual void sampleCoverage(WGC3Dclampf value, WGC3Dboolean invert); | |
| 286 virtual void scissor( | |
| 287 WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height); | |
| 288 virtual void shaderSource(WebGLId shader, const WGC3Dchar* source); | |
| 289 virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask); | |
| 290 virtual void stencilFuncSeparate( | |
| 291 WGC3Denum face, WGC3Denum func, WGC3Dint ref, WGC3Duint mask); | |
| 292 virtual void stencilMask(WGC3Duint mask); | |
| 293 virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask); | |
| 294 virtual void stencilOp(WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass); | |
| 295 virtual void stencilOpSeparate( | |
| 296 WGC3Denum face, | |
| 297 WGC3Denum fail, | |
| 298 WGC3Denum zfail, | |
| 299 WGC3Denum zpass); | |
| 300 | |
| 301 virtual void texImage2D( | |
| 302 WGC3Denum target, | |
| 303 WGC3Dint level, | |
| 304 WGC3Denum internalformat, | |
| 305 WGC3Dsizei width, | |
| 306 WGC3Dsizei height, | |
| 307 WGC3Dint border, | |
| 308 WGC3Denum format, | |
| 309 WGC3Denum type, | |
| 310 const void* pixels); | |
| 311 | |
| 312 virtual void texParameterf( | |
| 313 WGC3Denum target, WGC3Denum pname, WGC3Dfloat param); | |
| 314 virtual void texParameteri( | |
| 315 WGC3Denum target, WGC3Denum pname, WGC3Dint param); | |
| 316 | |
| 317 virtual void texSubImage2D( | |
| 318 WGC3Denum target, | |
| 319 WGC3Dint level, | |
| 320 WGC3Dint xoffset, | |
| 321 WGC3Dint yoffset, | |
| 322 WGC3Dsizei width, | |
| 323 WGC3Dsizei height, | |
| 324 WGC3Denum format, | |
| 325 WGC3Denum type, | |
| 326 const void* pixels); | |
| 327 | |
| 328 virtual void uniform1f(WGC3Dint location, WGC3Dfloat x); | |
| 329 virtual void uniform1fv(WGC3Dint location, WGC3Dsizei count, | |
| 330 const WGC3Dfloat* v); | |
| 331 virtual void uniform1i(WGC3Dint location, WGC3Dint x); | |
| 332 virtual void uniform1iv(WGC3Dint location, WGC3Dsizei count, | |
| 333 const WGC3Dint* v); | |
| 334 virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y); | |
| 335 virtual void uniform2fv(WGC3Dint location, WGC3Dsizei count, | |
| 336 const WGC3Dfloat* v); | |
| 337 virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y); | |
| 338 virtual void uniform2iv(WGC3Dint location, WGC3Dsizei count, | |
| 339 const WGC3Dint* v); | |
| 340 virtual void uniform3f(WGC3Dint location, | |
| 341 WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z); | |
| 342 virtual void uniform3fv(WGC3Dint location, WGC3Dsizei count, | |
| 343 const WGC3Dfloat* v); | |
| 344 virtual void uniform3i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z); | |
| 345 virtual void uniform3iv(WGC3Dint location, WGC3Dsizei count, | |
| 346 const WGC3Dint* v); | |
| 347 virtual void uniform4f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y, | |
| 348 WGC3Dfloat z, WGC3Dfloat w); | |
| 349 virtual void uniform4fv(WGC3Dint location, WGC3Dsizei count, | |
| 350 const WGC3Dfloat* v); | |
| 351 virtual void uniform4i(WGC3Dint location, WGC3Dint x, WGC3Dint y, | |
| 352 WGC3Dint z, WGC3Dint w); | |
| 353 virtual void uniform4iv(WGC3Dint location, WGC3Dsizei count, | |
| 354 const WGC3Dint* v); | |
| 355 virtual void uniformMatrix2fv( | |
| 356 WGC3Dint location, WGC3Dsizei count, | |
| 357 WGC3Dboolean transpose, const WGC3Dfloat* value); | |
| 358 virtual void uniformMatrix3fv( | |
| 359 WGC3Dint location, WGC3Dsizei count, | |
| 360 WGC3Dboolean transpose, const WGC3Dfloat* value); | |
| 361 virtual void uniformMatrix4fv( | |
| 362 WGC3Dint location, WGC3Dsizei count, | |
| 363 WGC3Dboolean transpose, const WGC3Dfloat* value); | |
| 364 | |
| 365 virtual void useProgram(WebGLId program); | |
| 366 virtual void validateProgram(WebGLId program); | |
| 367 | |
| 368 virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x); | |
| 369 virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values); | |
| 370 virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y); | |
| 371 virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values); | |
| 372 virtual void vertexAttrib3f( | |
| 373 WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z); | |
| 374 virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values); | |
| 375 virtual void vertexAttrib4f( | |
| 376 WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w); | |
| 377 virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values); | |
| 378 virtual void vertexAttribPointer( | |
| 379 WGC3Duint index, | |
| 380 WGC3Dint size, | |
| 381 WGC3Denum type, | |
| 382 WGC3Dboolean normalized, | |
| 383 WGC3Dsizei stride, | |
| 384 WGC3Dintptr offset); | |
| 385 | |
| 386 virtual void viewport( | |
| 387 WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height); | |
| 388 | |
| 389 // Support for buffer creation and deletion | |
| 390 virtual WebGLId createBuffer(); | |
| 391 virtual WebGLId createFramebuffer(); | |
| 392 virtual WebGLId createProgram(); | |
| 393 virtual WebGLId createRenderbuffer(); | |
| 394 virtual WebGLId createShader(WGC3Denum); | |
| 395 virtual WebGLId createTexture(); | |
| 396 | |
| 397 virtual void deleteBuffer(WebGLId); | |
| 398 virtual void deleteFramebuffer(WebGLId); | |
| 399 virtual void deleteProgram(WebGLId); | |
| 400 virtual void deleteRenderbuffer(WebGLId); | |
| 401 virtual void deleteShader(WebGLId); | |
| 402 virtual void deleteTexture(WebGLId); | |
| 403 | |
| 404 private: | |
| 405 // ANGLE related. | |
| 406 struct ShaderSourceEntry { | |
| 407 explicit ShaderSourceEntry(WGC3Denum shader_type) | |
| 408 : type(shader_type), | |
| 409 is_valid(false) { | |
| 410 } | |
| 411 | |
| 412 WGC3Denum type; | |
| 413 scoped_array<char> source; | |
| 414 scoped_array<char> log; | |
| 415 scoped_array<char> translated_source; | |
| 416 bool is_valid; | |
| 417 }; | |
| 418 | |
| 419 typedef base::hash_map<WebGLId, ShaderSourceEntry*> ShaderSourceMap; | |
| 420 | |
| 421 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | |
| 422 void FlipVertically(unsigned char* framebuffer, | |
| 423 unsigned int width, | |
| 424 unsigned int height); | |
| 425 #endif | |
| 426 | |
| 427 // Take into account the user's requested context creation attributes, in | |
| 428 // particular stencil and antialias, and determine which could or could | |
| 429 // not be honored based on the capabilities of the OpenGL implementation. | |
| 430 void ValidateAttributes(); | |
| 431 | |
| 432 // Resolve the given rectangle of the multisampled framebuffer if necessary. | |
| 433 void ResolveMultisampledFramebuffer( | |
| 434 WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height); | |
| 435 | |
| 436 bool AngleCreateCompilers(); | |
| 437 void AngleDestroyCompilers(); | |
| 438 bool AngleValidateShaderSource(ShaderSourceEntry* entry); | |
| 439 | |
| 440 WebGraphicsContext3D::Attributes attributes_; | |
| 441 bool initialized_; | |
| 442 bool render_directly_to_web_view_; | |
| 443 bool is_gles2_; | |
| 444 bool have_ext_framebuffer_object_; | |
| 445 bool have_ext_framebuffer_multisample_; | |
| 446 bool have_angle_framebuffer_multisample_; | |
| 447 | |
| 448 WebGLId texture_; | |
| 449 WebGLId fbo_; | |
| 450 WebGLId depth_stencil_buffer_; | |
| 451 int cached_width_, cached_height_; | |
| 452 | |
| 453 // For multisampling | |
| 454 WebGLId multisample_fbo_; | |
| 455 WebGLId multisample_depth_stencil_buffer_; | |
| 456 WebGLId multisample_color_buffer_; | |
| 457 | |
| 458 // For tracking which FBO is bound | |
| 459 WebGLId bound_fbo_; | |
| 460 | |
| 461 // For tracking which texture is bound | |
| 462 WebGLId bound_texture_; | |
| 463 | |
| 464 // FBO used for copying child texture to parent texture. | |
| 465 WebGLId copy_texture_to_parent_texture_fbo_; | |
| 466 | |
| 467 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | |
| 468 unsigned char* scanline_; | |
| 469 #endif | |
| 470 | |
| 471 // Errors raised by synthesizeGLError(). | |
| 472 std::list<WGC3Denum> synthetic_errors_list_; | |
| 473 std::set<WGC3Denum> synthetic_errors_set_; | |
| 474 | |
| 475 scoped_ptr<gfx::GLContext> gl_context_; | |
| 476 | |
| 477 ShaderSourceMap shader_source_map_; | |
| 478 | |
| 479 ShHandle fragment_compiler_; | |
| 480 ShHandle vertex_compiler_; | |
| 481 }; | |
| 482 | |
| 483 #else // USE_WGC3D_TYPES | |
| 484 | |
| 485 class WebGraphicsContext3DInProcessImpl : public WebKit::WebGraphicsContext3D { | 32 class WebGraphicsContext3DInProcessImpl : public WebKit::WebGraphicsContext3D { |
| 486 public: | 33 public: |
| 487 WebGraphicsContext3DInProcessImpl(); | 34 WebGraphicsContext3DInProcessImpl(); |
| 488 virtual ~WebGraphicsContext3DInProcessImpl(); | 35 virtual ~WebGraphicsContext3DInProcessImpl(); |
| 489 | 36 |
| 490 //---------------------------------------------------------------------- | 37 //---------------------------------------------------------------------- |
| 491 // WebGraphicsContext3D methods | 38 // WebGraphicsContext3D methods |
| 492 virtual bool initialize( | 39 virtual bool initialize( |
| 493 WebGraphicsContext3D::Attributes attributes, WebKit::WebView*, bool); | 40 WebGraphicsContext3D::Attributes attributes, WebKit::WebView*, bool); |
| 494 virtual bool makeContextCurrent(); | 41 virtual bool makeContextCurrent(); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 std::set<unsigned long> synthetic_errors_set_; | 467 std::set<unsigned long> synthetic_errors_set_; |
| 921 | 468 |
| 922 scoped_ptr<gfx::GLContext> gl_context_; | 469 scoped_ptr<gfx::GLContext> gl_context_; |
| 923 | 470 |
| 924 ShaderSourceMap shader_source_map_; | 471 ShaderSourceMap shader_source_map_; |
| 925 | 472 |
| 926 ShHandle fragment_compiler_; | 473 ShHandle fragment_compiler_; |
| 927 ShHandle vertex_compiler_; | 474 ShHandle vertex_compiler_; |
| 928 }; | 475 }; |
| 929 | 476 |
| 930 #endif // USE_WGC3D_TYPES | |
| 931 | |
| 932 } // namespace gpu | 477 } // namespace gpu |
| 933 } // namespace webkit | 478 } // namespace webkit |
| 934 | 479 |
| 935 #endif // WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ | 480 #endif // WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ |
| 936 | 481 |
| OLD | NEW |