Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 class WebGLDrawBuffers; | 84 class WebGLDrawBuffers; |
| 85 class WebGLExtension; | 85 class WebGLExtension; |
| 86 class WebGLFramebuffer; | 86 class WebGLFramebuffer; |
| 87 class WebGLLoseContext; | 87 class WebGLLoseContext; |
| 88 class WebGLObject; | 88 class WebGLObject; |
| 89 class WebGLProgram; | 89 class WebGLProgram; |
| 90 class WebGLRenderbuffer; | 90 class WebGLRenderbuffer; |
| 91 class WebGLShader; | 91 class WebGLShader; |
| 92 class WebGLShaderPrecisionFormat; | 92 class WebGLShaderPrecisionFormat; |
| 93 class WebGLSharedObject; | 93 class WebGLSharedObject; |
| 94 class WebGLSharedWebGraphicsContext3D; | |
| 94 class WebGLTexture; | 95 class WebGLTexture; |
| 95 class WebGLUniformLocation; | 96 class WebGLUniformLocation; |
| 96 class WebGLVertexArrayObjectOES; | 97 class WebGLVertexArrayObjectOES; |
| 97 | 98 |
| 98 class WebGLRenderingContextLostCallback; | 99 class WebGLRenderingContextLostCallback; |
| 99 class WebGLRenderingContextErrorMessageCallback; | 100 class WebGLRenderingContextErrorMessageCallback; |
| 100 | 101 |
| 101 class WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOM Object, public Page::MultisamplingChangedObserver { | 102 class WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOM Object, public Page::MultisamplingChangedObserver { |
| 102 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); | 103 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); |
| 103 public: | 104 public: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 void clearStencil(GLint); | 141 void clearStencil(GLint); |
| 141 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha); | 142 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha); |
| 142 void compileShader(WebGLShader*); | 143 void compileShader(WebGLShader*); |
| 143 | 144 |
| 144 void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data); | 145 void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data); |
| 145 void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin t yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data); | 146 void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin t yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data); |
| 146 | 147 |
| 147 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); | 148 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); |
| 148 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLint x, GLint y, GLsizei width, GLsizei height); | 149 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLint x, GLint y, GLsizei width, GLsizei height); |
| 149 | 150 |
| 150 PassRefPtr<WebGLBuffer> createBuffer(); | 151 PassRefPtrWillBeRawPtr<WebGLBuffer> createBuffer(); |
| 151 PassRefPtr<WebGLFramebuffer> createFramebuffer(); | 152 PassRefPtrWillBeRawPtr<WebGLFramebuffer> createFramebuffer(); |
| 152 PassRefPtr<WebGLProgram> createProgram(); | 153 PassRefPtrWillBeRawPtr<WebGLProgram> createProgram(); |
| 153 PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); | 154 PassRefPtrWillBeRawPtr<WebGLRenderbuffer> createRenderbuffer(); |
| 154 PassRefPtr<WebGLShader> createShader(GLenum type); | 155 PassRefPtrWillBeRawPtr<WebGLShader> createShader(GLenum type); |
| 155 PassRefPtr<WebGLTexture> createTexture(); | 156 PassRefPtrWillBeRawPtr<WebGLTexture> createTexture(); |
| 156 | 157 |
| 157 void cullFace(GLenum mode); | 158 void cullFace(GLenum mode); |
| 158 | 159 |
| 159 void deleteBuffer(WebGLBuffer*); | 160 void deleteBuffer(WebGLBuffer*); |
| 160 void deleteFramebuffer(WebGLFramebuffer*); | 161 void deleteFramebuffer(WebGLFramebuffer*); |
| 161 void deleteProgram(WebGLProgram*); | 162 void deleteProgram(WebGLProgram*); |
| 162 void deleteRenderbuffer(WebGLRenderbuffer*); | 163 void deleteRenderbuffer(WebGLRenderbuffer*); |
| 163 void deleteShader(WebGLShader*); | 164 void deleteShader(WebGLShader*); |
| 164 void deleteTexture(WebGLTexture*); | 165 void deleteTexture(WebGLTexture*); |
| 165 | 166 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 177 | 178 |
| 178 void enable(GLenum cap); | 179 void enable(GLenum cap); |
| 179 void enableVertexAttribArray(GLuint index); | 180 void enableVertexAttribArray(GLuint index); |
| 180 void finish(); | 181 void finish(); |
| 181 void flush(); | 182 void flush(); |
| 182 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*); | 183 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*); |
| 183 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level); | 184 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level); |
| 184 void frontFace(GLenum mode); | 185 void frontFace(GLenum mode); |
| 185 void generateMipmap(GLenum target); | 186 void generateMipmap(GLenum target); |
| 186 | 187 |
| 187 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index); | 188 PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuin t index); |
| 188 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index); | 189 PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLui nt index); |
| 189 Nullable<Vector<RefPtr<WebGLShader> > > getAttachedShaders(WebGLProgram*); | 190 bool getAttachedShaders(WebGLProgram*, WillBeHeapVector<RefPtrWillBeMember<W ebGLShader> >&); |
| 191 Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > > getAttachedSha ders(WebGLProgram*); | |
| 190 GLint getAttribLocation(WebGLProgram*, const String& name); | 192 GLint getAttribLocation(WebGLProgram*, const String& name); |
| 191 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname); | 193 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname); |
| 192 PassRefPtr<WebGLContextAttributes> getContextAttributes(); | 194 PassRefPtrWillBeRawPtr<WebGLContextAttributes> getContextAttributes(); |
| 193 GLenum getError(); | 195 GLenum getError(); |
| 194 PassRefPtr<WebGLExtension> getExtension(const String& name); | 196 PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(const String& name); |
| 195 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname); | 197 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname); |
| 196 WebGLGetInfo getParameter(GLenum pname); | 198 WebGLGetInfo getParameter(GLenum pname); |
| 197 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname); | 199 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname); |
| 198 String getProgramInfoLog(WebGLProgram*); | 200 String getProgramInfoLog(WebGLProgram*); |
| 199 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname); | 201 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname); |
| 200 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname); | 202 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname); |
| 201 String getShaderInfoLog(WebGLShader*); | 203 String getShaderInfoLog(WebGLShader*); |
| 202 PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shade rType, GLenum precisionType); | 204 PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat( GLenum shaderType, GLenum precisionType); |
| 203 String getShaderSource(WebGLShader*); | 205 String getShaderSource(WebGLShader*); |
| 204 Nullable<Vector<String> > getSupportedExtensions(); | 206 Nullable<Vector<String> > getSupportedExtensions(); |
| 205 WebGLGetInfo getTexParameter(GLenum target, GLenum pname); | 207 WebGLGetInfo getTexParameter(GLenum target, GLenum pname); |
| 206 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*); | 208 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*); |
| 207 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const Str ing&); | 209 PassRefPtrWillBeRawPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram *, const String&); |
| 208 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname); | 210 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname); |
| 209 long long getVertexAttribOffset(GLuint index, GLenum pname); | 211 long long getVertexAttribOffset(GLuint index, GLenum pname); |
| 210 | 212 |
| 211 void hint(GLenum target, GLenum mode); | 213 void hint(GLenum target, GLenum mode); |
| 212 GLboolean isBuffer(WebGLBuffer*); | 214 GLboolean isBuffer(WebGLBuffer*); |
| 213 bool isContextLost() const; | 215 bool isContextLost() const; |
| 214 GLboolean isEnabled(GLenum cap); | 216 GLboolean isEnabled(GLenum cap); |
| 215 GLboolean isFramebuffer(WebGLFramebuffer*); | 217 GLboolean isFramebuffer(WebGLFramebuffer*); |
| 216 GLboolean isProgram(WebGLProgram*); | 218 GLboolean isProgram(WebGLProgram*); |
| 217 GLboolean isRenderbuffer(WebGLRenderbuffer*); | 219 GLboolean isRenderbuffer(WebGLRenderbuffer*); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 void removeSharedObject(WebGLSharedObject*); | 345 void removeSharedObject(WebGLSharedObject*); |
| 344 void removeContextObject(WebGLContextObject*); | 346 void removeContextObject(WebGLContextObject*); |
| 345 | 347 |
| 346 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } | 348 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } |
| 347 | 349 |
| 348 // ActiveDOMObject notifications | 350 // ActiveDOMObject notifications |
| 349 virtual bool hasPendingActivity() const OVERRIDE; | 351 virtual bool hasPendingActivity() const OVERRIDE; |
| 350 virtual void stop() OVERRIDE; | 352 virtual void stop() OVERRIDE; |
| 351 | 353 |
| 352 void setSavingImage(bool isSaving) { m_savingImage = isSaving; } | 354 void setSavingImage(bool isSaving) { m_savingImage = isSaving; } |
| 355 | |
| 356 virtual void trace(Visitor*) OVERRIDE; | |
| 357 | |
| 358 class TextureUnitState { | |
| 359 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 360 public: | |
| 361 RefPtrWillBeMember<WebGLTexture> m_texture2DBinding; | |
| 362 RefPtrWillBeMember<WebGLTexture> m_textureCubeMapBinding; | |
| 363 | |
| 364 void trace(Visitor*); | |
| 365 }; | |
| 366 | |
| 353 protected: | 367 protected: |
| 354 friend class WebGLDrawBuffers; | 368 friend class WebGLDrawBuffers; |
| 355 friend class WebGLFramebuffer; | 369 friend class WebGLFramebuffer; |
| 356 friend class WebGLObject; | 370 friend class WebGLObject; |
| 371 friend class WebGLContextObject; | |
| 357 friend class OESVertexArrayObject; | 372 friend class OESVertexArrayObject; |
| 358 friend class WebGLDebugShaders; | 373 friend class WebGLDebugShaders; |
| 359 friend class WebGLCompressedTextureATC; | 374 friend class WebGLCompressedTextureATC; |
| 360 friend class WebGLCompressedTextureETC1; | 375 friend class WebGLCompressedTextureETC1; |
| 361 friend class WebGLCompressedTexturePVRTC; | 376 friend class WebGLCompressedTexturePVRTC; |
| 362 friend class WebGLCompressedTextureS3TC; | 377 friend class WebGLCompressedTextureS3TC; |
| 363 friend class WebGLRenderingContextErrorMessageCallback; | 378 friend class WebGLRenderingContextErrorMessageCallback; |
| 364 friend class WebGLVertexArrayObjectOES; | 379 friend class WebGLVertexArrayObjectOES; |
| 365 friend class ScopedTexture2DRestorer; | 380 friend class ScopedTexture2DRestorer; |
| 366 | 381 |
| 367 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*); | 382 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*); |
| 368 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsC ontext3D>); | 383 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsC ontext3D>); |
| 369 void initializeNewContext(); | 384 void initializeNewContext(); |
| 370 void setupFlags(); | 385 void setupFlags(); |
| 371 | 386 |
| 387 #if ENABLE(OILPAN) | |
| 388 PassRefPtr<WebGLSharedWebGraphicsContext3D> sharedWebGraphicsContext3D(); | |
| 389 #endif | |
| 390 | |
| 372 void addSharedObject(WebGLSharedObject*); | 391 void addSharedObject(WebGLSharedObject*); |
| 373 void addContextObject(WebGLContextObject*); | 392 void addContextObject(WebGLContextObject*); |
| 374 void detachAndRemoveAllObjects(); | 393 void detachAndRemoveAllObjects(); |
| 375 | 394 |
| 376 void destroyContext(); | 395 void destroyContext(); |
| 377 void markContextChanged(ContentChangeType); | 396 void markContextChanged(ContentChangeType); |
| 378 | 397 |
| 379 // Query if the GL implementation is NPOT strict. | 398 // Query if the GL implementation is NPOT strict. |
| 380 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } | 399 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } |
| 381 // Query if depth_stencil buffer is supported. | 400 // Query if depth_stencil buffer is supported. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 396 | 415 |
| 397 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const c har* functionName); | 416 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const c har* functionName); |
| 398 | 417 |
| 399 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); | 418 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); |
| 400 | 419 |
| 401 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*); | 420 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*); |
| 402 | 421 |
| 403 // Structure for rendering to a DrawingBuffer, instead of directly | 422 // Structure for rendering to a DrawingBuffer, instead of directly |
| 404 // to the back-buffer of m_context. | 423 // to the back-buffer of m_context. |
| 405 RefPtr<DrawingBuffer> m_drawingBuffer; | 424 RefPtr<DrawingBuffer> m_drawingBuffer; |
| 425 #if ENABLE(OILPAN) | |
| 426 RefPtr<WebGLSharedWebGraphicsContext3D> m_sharedWebGraphicsContext3D; | |
| 427 #endif | |
| 428 | |
| 406 RefPtr<WebGLContextGroup> m_contextGroup; | 429 RefPtr<WebGLContextGroup> m_contextGroup; |
| 407 | 430 |
| 408 // Dispatches a context lost event once it is determined that one is needed. | 431 // Dispatches a context lost event once it is determined that one is needed. |
| 409 // This is used both for synthetic and real context losses. For real ones, i t's | 432 // This is used both for synthetic and real context losses. For real ones, i t's |
| 410 // likely that there's no JavaScript on the stack, but that might be depende nt | 433 // likely that there's no JavaScript on the stack, but that might be depende nt |
| 411 // on how exactly the platform discovers that the context was lost. For bett er | 434 // on how exactly the platform discovers that the context was lost. For bett er |
| 412 // portability we always defer the dispatch of the event. | 435 // portability we always defer the dispatch of the event. |
| 413 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; | 436 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; |
| 414 bool m_restoreAllowed; | 437 bool m_restoreAllowed; |
| 415 Timer<WebGLRenderingContextBase> m_restoreTimer; | 438 Timer<WebGLRenderingContextBase> m_restoreTimer; |
| 416 | 439 |
| 417 bool m_needsUpdate; | 440 bool m_needsUpdate; |
| 418 bool m_markedCanvasDirty; | 441 bool m_markedCanvasDirty; |
| 419 HashSet<WebGLContextObject*> m_contextObjects; | 442 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObje cts; |
| 420 | 443 |
| 421 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; | 444 OwnPtrWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallbackA dapter; |
| 422 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter; | 445 OwnPtrWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMessage CallbackAdapter; |
| 423 | 446 |
| 424 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER | 447 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER |
| 425 RefPtr<WebGLBuffer> m_boundArrayBuffer; | 448 RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer; |
| 426 | 449 |
| 427 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; | 450 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; |
| 428 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; | 451 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; |
| 429 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayOb ject) | 452 void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObject OES> arrayObject) |
| 430 { | 453 { |
| 431 if (arrayObject) | 454 if (arrayObject) |
| 432 m_boundVertexArrayObject = arrayObject; | 455 m_boundVertexArrayObject = arrayObject; |
| 433 else | 456 else |
| 434 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 457 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 435 } | 458 } |
| 436 | 459 |
| 437 class VertexAttribValue { | 460 class VertexAttribValue { |
| 438 public: | 461 public: |
| 439 VertexAttribValue() | 462 VertexAttribValue() |
| 440 { | 463 { |
| 441 initValue(); | 464 initValue(); |
| 442 } | 465 } |
| 443 | 466 |
| 444 void initValue() | 467 void initValue() |
| 445 { | 468 { |
| 446 value[0] = 0.0f; | 469 value[0] = 0.0f; |
| 447 value[1] = 0.0f; | 470 value[1] = 0.0f; |
| 448 value[2] = 0.0f; | 471 value[2] = 0.0f; |
| 449 value[3] = 1.0f; | 472 value[3] = 1.0f; |
| 450 } | 473 } |
| 451 | 474 |
| 452 GLfloat value[4]; | 475 GLfloat value[4]; |
| 453 }; | 476 }; |
| 454 Vector<VertexAttribValue> m_vertexAttribValue; | 477 Vector<VertexAttribValue> m_vertexAttribValue; |
| 455 unsigned m_maxVertexAttribs; | 478 unsigned m_maxVertexAttribs; |
| 456 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; | 479 RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer; |
| 457 long m_vertexAttrib0BufferSize; | 480 long m_vertexAttrib0BufferSize; |
| 458 GLfloat m_vertexAttrib0BufferValue[4]; | 481 GLfloat m_vertexAttrib0BufferValue[4]; |
| 459 bool m_forceAttrib0BufferRefill; | 482 bool m_forceAttrib0BufferRefill; |
| 460 bool m_vertexAttrib0UsedBefore; | 483 bool m_vertexAttrib0UsedBefore; |
| 461 | 484 |
| 462 RefPtr<WebGLProgram> m_currentProgram; | 485 RefPtrWillBeMember<WebGLProgram> m_currentProgram; |
| 463 RefPtr<WebGLFramebuffer> m_framebufferBinding; | 486 RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; |
| 464 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; | 487 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding; |
| 465 class TextureUnitState { | 488 |
| 466 public: | 489 WillBeHeapVector<TextureUnitState> m_textureUnits; |
| 467 RefPtr<WebGLTexture> m_texture2DBinding; | |
| 468 RefPtr<WebGLTexture> m_textureCubeMapBinding; | |
| 469 }; | |
| 470 Vector<TextureUnitState> m_textureUnits; | |
| 471 unsigned long m_activeTextureUnit; | 490 unsigned long m_activeTextureUnit; |
| 472 | 491 |
| 473 RefPtr<WebGLTexture> m_blackTexture2D; | 492 RefPtrWillBeMember<WebGLTexture> m_blackTexture2D; |
| 474 RefPtr<WebGLTexture> m_blackTextureCubeMap; | 493 RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap; |
| 475 | 494 |
| 476 Vector<GLenum> m_compressedTextureFormats; | 495 Vector<GLenum> m_compressedTextureFormats; |
| 477 | 496 |
| 478 // Fixed-size cache of reusable image buffers for video texImage2D calls. | 497 // Fixed-size cache of reusable image buffers for video texImage2D calls. |
| 479 class LRUImageBufferCache { | 498 class LRUImageBufferCache { |
| 480 public: | 499 public: |
| 481 LRUImageBufferCache(int capacity); | 500 LRUImageBufferCache(int capacity); |
| 482 // The pointer returned is owned by the image buffer map. | 501 // The pointer returned is owned by the image buffer map. |
| 483 ImageBuffer* imageBuffer(const IntSize& size); | 502 ImageBuffer* imageBuffer(const IntSize& size); |
| 484 private: | 503 private: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 501 bool m_drawBuffersWebGLRequirementsChecked; | 520 bool m_drawBuffersWebGLRequirementsChecked; |
| 502 bool m_drawBuffersSupported; | 521 bool m_drawBuffersSupported; |
| 503 | 522 |
| 504 GLint m_packAlignment; | 523 GLint m_packAlignment; |
| 505 GLint m_unpackAlignment; | 524 GLint m_unpackAlignment; |
| 506 bool m_unpackFlipY; | 525 bool m_unpackFlipY; |
| 507 bool m_unpackPremultiplyAlpha; | 526 bool m_unpackPremultiplyAlpha; |
| 508 GLenum m_unpackColorspaceConversion; | 527 GLenum m_unpackColorspaceConversion; |
| 509 bool m_contextLost; | 528 bool m_contextLost; |
| 510 LostContextMode m_contextLostMode; | 529 LostContextMode m_contextLostMode; |
| 511 RefPtr<WebGLContextAttributes> m_requestedAttributes; | 530 RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes; |
| 512 | 531 |
| 513 bool m_layerCleared; | 532 bool m_layerCleared; |
| 514 GLfloat m_clearColor[4]; | 533 GLfloat m_clearColor[4]; |
| 515 bool m_scissorEnabled; | 534 bool m_scissorEnabled; |
| 516 GLfloat m_clearDepth; | 535 GLfloat m_clearDepth; |
| 517 GLint m_clearStencil; | 536 GLint m_clearStencil; |
| 518 GLboolean m_colorMask[4]; | 537 GLboolean m_colorMask[4]; |
| 519 GLboolean m_depthMask; | 538 GLboolean m_depthMask; |
| 520 | 539 |
| 521 bool m_stencilEnabled; | 540 bool m_stencilEnabled; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 538 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 557 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 539 | 558 |
| 540 bool m_savingImage; | 559 bool m_savingImage; |
| 541 | 560 |
| 542 enum ExtensionFlags { | 561 enum ExtensionFlags { |
| 543 ApprovedExtension = 0x00, | 562 ApprovedExtension = 0x00, |
| 544 // Extension that is behind the draft extensions runtime flag: | 563 // Extension that is behind the draft extensions runtime flag: |
| 545 DraftExtension = 0x01, | 564 DraftExtension = 0x01, |
| 546 }; | 565 }; |
| 547 | 566 |
| 548 class ExtensionTracker { | 567 class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracke r> { |
| 549 public: | 568 public: |
| 550 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) | 569 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) |
| 551 : m_draft(flags & DraftExtension) | 570 : m_draft(flags & DraftExtension) |
| 552 , m_prefixes(prefixes) | 571 , m_prefixes(prefixes) |
| 553 { | 572 { |
| 554 } | 573 } |
| 555 | 574 |
| 575 #if !ENABLE(OILPAN) | |
| 556 virtual ~ExtensionTracker() | 576 virtual ~ExtensionTracker() |
| 557 { | 577 { |
| 558 } | 578 } |
| 579 #endif | |
| 559 | 580 |
| 560 bool draft() const | 581 bool draft() const |
| 561 { | 582 { |
| 562 return m_draft; | 583 return m_draft; |
| 563 } | 584 } |
| 564 | 585 |
| 565 const char* const* prefixes() const; | 586 const char* const* prefixes() const; |
| 566 bool matchesNameWithPrefixes(const String&) const; | 587 bool matchesNameWithPrefixes(const String&) const; |
| 567 | 588 |
| 568 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e*) = 0; | 589 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase*) = 0; |
| 569 virtual bool supported(WebGLRenderingContextBase*) const = 0; | 590 virtual bool supported(WebGLRenderingContextBase*) const = 0; |
| 570 virtual const char* extensionName() const = 0; | 591 virtual const char* extensionName() const = 0; |
| 571 virtual void loseExtension() = 0; | 592 virtual void loseExtension() = 0; |
| 572 | 593 |
| 594 virtual void trace(Visitor*) { } | |
| 595 | |
| 573 private: | 596 private: |
| 574 bool m_draft; | 597 bool m_draft; |
| 575 const char* const* m_prefixes; | 598 const char* const* m_prefixes; |
| 576 }; | 599 }; |
| 577 | 600 |
| 578 template <typename T> | 601 template <typename T> |
| 579 class TypedExtensionTracker FINAL : public ExtensionTracker { | 602 class TypedExtensionTracker FINAL : public ExtensionTracker { |
| 580 public: | 603 public: |
| 581 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes) | 604 static PassOwnPtrWillBeRawPtr<TypedExtensionTracker<T> > create(RefPtrWi llBeMember<T>& extensionField, ExtensionFlags flags, const char* const* prefixes ) |
| 582 : ExtensionTracker(flags, prefixes) | |
| 583 , m_extensionField(extensionField) | |
| 584 , m_extension(nullptr) | |
| 585 { | 605 { |
| 606 return adoptPtrWillBeNoop(new TypedExtensionTracker<T>(extensionFiel d, flags, prefixes)); | |
| 586 } | 607 } |
| 587 | 608 |
| 609 #if !ENABLE(OILPAN) | |
| 588 virtual ~TypedExtensionTracker() | 610 virtual ~TypedExtensionTracker() |
| 589 { | 611 { |
| 590 if (m_extension) { | 612 if (m_extension) { |
| 591 m_extension->lose(true); | 613 m_extension->lose(true); |
| 592 m_extension = nullptr; | 614 m_extension = nullptr; |
| 593 } | 615 } |
| 594 } | 616 } |
| 617 #endif | |
| 595 | 618 |
| 596 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e* context) OVERRIDE | 619 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase* context) OVERRIDE |
| 597 { | 620 { |
| 598 if (!m_extension) { | 621 if (!m_extension) { |
| 599 m_extension = T::create(context); | 622 m_extension = T::create(context); |
|
haraken
2014/07/15 15:04:56
Just to confirm: It's guaranteed that T holds a st
sof
2014/07/15 16:23:00
No, the extension (a WebGLExtension) holds a weak
haraken
2014/07/16 02:08:19
Then why don't we need to call m_extension->lose()
sof
2014/07/16 05:02:48
If the extension tracker dies, then WebGLRendering
| |
| 600 m_extensionField = m_extension; | 623 m_extensionField = m_extension; |
| 601 } | 624 } |
| 602 | 625 |
| 603 return m_extension; | 626 return m_extension; |
| 604 } | 627 } |
| 605 | 628 |
| 606 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E | 629 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E |
| 607 { | 630 { |
| 608 return T::supported(context); | 631 return T::supported(context); |
| 609 } | 632 } |
| 610 | 633 |
| 611 virtual const char* extensionName() const OVERRIDE | 634 virtual const char* extensionName() const OVERRIDE |
| 612 { | 635 { |
| 613 return T::extensionName(); | 636 return T::extensionName(); |
| 614 } | 637 } |
| 615 | 638 |
| 616 virtual void loseExtension() OVERRIDE | 639 virtual void loseExtension() OVERRIDE |
| 617 { | 640 { |
| 618 if (m_extension) { | 641 if (m_extension) { |
| 619 m_extension->lose(false); | 642 m_extension->lose(false); |
| 620 if (m_extension->isLost()) | 643 if (m_extension->isLost()) |
| 621 m_extension = nullptr; | 644 m_extension = nullptr; |
| 622 } | 645 } |
| 623 } | 646 } |
| 624 | 647 |
| 648 virtual void trace(Visitor* visitor) OVERRIDE | |
| 649 { | |
| 650 visitor->trace(m_extension); | |
| 651 visitor->trace(m_extensionField); | |
| 652 ExtensionTracker::trace(visitor); | |
| 653 } | |
| 654 | |
| 625 private: | 655 private: |
| 626 RefPtr<T>& m_extensionField; | 656 TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFl ags flags, const char* const* prefixes) |
| 657 : ExtensionTracker(flags, prefixes) | |
| 658 , m_extensionField(extensionField) | |
| 659 { | |
| 660 } | |
| 661 | |
| 662 RefPtrWillBeMember<T>& m_extensionField; | |
| 627 // ExtensionTracker holds it's own reference to the extension to ensure | 663 // ExtensionTracker holds it's own reference to the extension to ensure |
| 628 // that it is not deleted before this object's destructor is called | 664 // that it is not deleted before this object's destructor is called |
| 629 RefPtr<T> m_extension; | 665 RefPtrWillBeMember<T> m_extension; |
| 630 }; | 666 }; |
| 631 | 667 |
| 632 bool m_extensionEnabled[WebGLExtensionNameCount]; | 668 bool m_extensionEnabled[WebGLExtensionNameCount]; |
| 633 Vector<ExtensionTracker*> m_extensions; | 669 WillBeHeapVector<OwnPtrWillBeMember<ExtensionTracker> > m_extensions; |
| 634 | 670 |
| 635 template <typename T> | 671 template <typename T> |
| 636 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char* const* prefixes = 0) | 672 void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags f lags = ApprovedExtension, const char* const* prefixes = 0) |
| 637 { | 673 { |
| 638 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes)); | 674 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags , prefixes)); |
| 639 } | 675 } |
| 640 | 676 |
| 641 bool extensionSupportedAndAllowed(const ExtensionTracker*); | 677 bool extensionSupportedAndAllowed(const ExtensionTracker*); |
| 642 | 678 |
| 643 inline bool extensionEnabled(WebGLExtensionName name) | 679 inline bool extensionEnabled(WebGLExtensionName name) |
| 644 { | 680 { |
| 645 return m_extensionEnabled[name]; | 681 return m_extensionEnabled[name]; |
| 646 } | 682 } |
| 647 | 683 |
| 648 // Errors raised by synthesizeGLError() while the context is lost. | 684 // Errors raised by synthesizeGLError() while the context is lost. |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 // Return the least recently used context's position in the active context v ector. | 938 // Return the least recently used context's position in the active context v ector. |
| 903 // If the vector is empty, return the maximum allowed active context number. | 939 // If the vector is empty, return the maximum allowed active context number. |
| 904 static size_t oldestContextIndex(); | 940 static size_t oldestContextIndex(); |
| 905 static IntSize oldestContextSize(); | 941 static IntSize oldestContextSize(); |
| 906 }; | 942 }; |
| 907 | 943 |
| 908 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); | 944 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); |
| 909 | 945 |
| 910 } // namespace WebCore | 946 } // namespace WebCore |
| 911 | 947 |
| 948 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(WebCore::WebGLRenderingContex tBase::TextureUnitState); | |
| 949 | |
| 912 #endif // WebGLRenderingContextBase_h | 950 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |