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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 // Lost context provoked by WEBKIT_lose_context. | 324 // Lost context provoked by WEBKIT_lose_context. |
| 323 SyntheticLostContext, | 325 SyntheticLostContext, |
| 324 | 326 |
| 325 // A synthetic lost context that should attempt to recover automatically | 327 // A synthetic lost context that should attempt to recover automatically |
| 326 AutoRecoverSyntheticLostContext | 328 AutoRecoverSyntheticLostContext |
| 327 }; | 329 }; |
| 328 void forceLostContext(LostContextMode); | 330 void forceLostContext(LostContextMode); |
| 329 void forceRestoreContext(); | 331 void forceRestoreContext(); |
| 330 void loseContextImpl(LostContextMode); | 332 void loseContextImpl(LostContextMode); |
| 331 | 333 |
| 332 blink::WebGraphicsContext3D* webContext() const { return m_drawingBuffer->co ntext(); } | 334 blink::WebGraphicsContext3D* webContext() const { return drawingBuffer()->co ntext(); } |
| 333 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } | 335 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } |
| 334 virtual blink::WebLayer* platformLayer() const OVERRIDE; | 336 virtual blink::WebLayer* platformLayer() const OVERRIDE; |
| 335 Extensions3DUtil* extensionsUtil(); | 337 Extensions3DUtil* extensionsUtil(); |
| 336 | 338 |
| 337 void reshape(int width, int height); | 339 void reshape(int width, int height); |
| 338 | 340 |
| 339 void markLayerComposited(); | 341 void markLayerComposited(); |
| 340 virtual void paintRenderingResultsToCanvas() OVERRIDE; | 342 virtual void paintRenderingResultsToCanvas() OVERRIDE; |
| 341 PassRefPtrWillBeRawPtr<ImageData> paintRenderingResultsToImageData(); | 343 PassRefPtrWillBeRawPtr<ImageData> paintRenderingResultsToImageData(); |
| 342 | 344 |
| 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() con st; | |
| 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 13 matching lines...) Expand all Loading... | |
| 395 void removeAllCompressedTextureFormats(); | 414 void removeAllCompressedTextureFormats(); |
| 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. |
| 424 #if ENABLE(OILPAN) | |
| 425 RefPtr<WebGLSharedWebGraphicsContext3D> m_sharedWebGraphicsContext3D; | |
| 426 #else | |
| 405 RefPtr<DrawingBuffer> m_drawingBuffer; | 427 RefPtr<DrawingBuffer> m_drawingBuffer; |
| 428 #endif | |
| 429 DrawingBuffer* drawingBuffer() const; | |
| 430 | |
| 406 RefPtr<WebGLContextGroup> m_contextGroup; | 431 RefPtr<WebGLContextGroup> m_contextGroup; |
| 407 | 432 |
| 408 // Dispatches a context lost event once it is determined that one is needed. | 433 // 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 | 434 // 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 | 435 // 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 | 436 // on how exactly the platform discovers that the context was lost. For bett er |
| 412 // portability we always defer the dispatch of the event. | 437 // portability we always defer the dispatch of the event. |
| 413 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; | 438 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; |
| 414 bool m_restoreAllowed; | 439 bool m_restoreAllowed; |
| 415 Timer<WebGLRenderingContextBase> m_restoreTimer; | 440 Timer<WebGLRenderingContextBase> m_restoreTimer; |
| 416 | 441 |
| 417 bool m_needsUpdate; | 442 bool m_needsUpdate; |
| 418 bool m_markedCanvasDirty; | 443 bool m_markedCanvasDirty; |
| 419 HashSet<WebGLContextObject*> m_contextObjects; | 444 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObje cts; |
| 420 | 445 |
| 421 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; | 446 OwnPtrWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallbackA dapter; |
| 422 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter; | 447 OwnPtrWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMessage CallbackAdapter; |
| 423 | 448 |
| 424 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER | 449 // 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; | 450 RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer; |
| 426 | 451 |
| 427 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; | 452 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; |
| 428 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; | 453 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; |
| 429 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayOb ject) | 454 void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObject OES> arrayObject) |
| 430 { | 455 { |
| 431 if (arrayObject) | 456 if (arrayObject) |
| 432 m_boundVertexArrayObject = arrayObject; | 457 m_boundVertexArrayObject = arrayObject; |
| 433 else | 458 else |
| 434 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 459 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 435 } | 460 } |
| 436 | 461 |
| 437 class VertexAttribValue { | 462 class VertexAttribValue { |
| 438 public: | 463 public: |
| 439 VertexAttribValue() | 464 VertexAttribValue() |
| 440 { | 465 { |
| 441 initValue(); | 466 initValue(); |
| 442 } | 467 } |
| 443 | 468 |
| 444 void initValue() | 469 void initValue() |
| 445 { | 470 { |
| 446 value[0] = 0.0f; | 471 value[0] = 0.0f; |
| 447 value[1] = 0.0f; | 472 value[1] = 0.0f; |
| 448 value[2] = 0.0f; | 473 value[2] = 0.0f; |
| 449 value[3] = 1.0f; | 474 value[3] = 1.0f; |
| 450 } | 475 } |
| 451 | 476 |
| 452 GLfloat value[4]; | 477 GLfloat value[4]; |
| 453 }; | 478 }; |
| 454 Vector<VertexAttribValue> m_vertexAttribValue; | 479 Vector<VertexAttribValue> m_vertexAttribValue; |
| 455 unsigned m_maxVertexAttribs; | 480 unsigned m_maxVertexAttribs; |
| 456 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; | 481 RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer; |
| 457 long m_vertexAttrib0BufferSize; | 482 long m_vertexAttrib0BufferSize; |
| 458 GLfloat m_vertexAttrib0BufferValue[4]; | 483 GLfloat m_vertexAttrib0BufferValue[4]; |
| 459 bool m_forceAttrib0BufferRefill; | 484 bool m_forceAttrib0BufferRefill; |
| 460 bool m_vertexAttrib0UsedBefore; | 485 bool m_vertexAttrib0UsedBefore; |
| 461 | 486 |
| 462 RefPtr<WebGLProgram> m_currentProgram; | 487 RefPtrWillBeMember<WebGLProgram> m_currentProgram; |
| 463 RefPtr<WebGLFramebuffer> m_framebufferBinding; | 488 RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; |
| 464 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; | 489 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding; |
| 465 class TextureUnitState { | 490 |
| 466 public: | 491 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; | 492 unsigned long m_activeTextureUnit; |
| 472 | 493 |
| 473 RefPtr<WebGLTexture> m_blackTexture2D; | 494 RefPtrWillBeMember<WebGLTexture> m_blackTexture2D; |
| 474 RefPtr<WebGLTexture> m_blackTextureCubeMap; | 495 RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap; |
| 475 | 496 |
| 476 Vector<GLenum> m_compressedTextureFormats; | 497 Vector<GLenum> m_compressedTextureFormats; |
| 477 | 498 |
| 478 // Fixed-size cache of reusable image buffers for video texImage2D calls. | 499 // Fixed-size cache of reusable image buffers for video texImage2D calls. |
| 479 class LRUImageBufferCache { | 500 class LRUImageBufferCache { |
| 480 public: | 501 public: |
| 481 LRUImageBufferCache(int capacity); | 502 LRUImageBufferCache(int capacity); |
| 482 // The pointer returned is owned by the image buffer map. | 503 // The pointer returned is owned by the image buffer map. |
| 483 ImageBuffer* imageBuffer(const IntSize& size); | 504 ImageBuffer* imageBuffer(const IntSize& size); |
| 484 private: | 505 private: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 501 bool m_drawBuffersWebGLRequirementsChecked; | 522 bool m_drawBuffersWebGLRequirementsChecked; |
| 502 bool m_drawBuffersSupported; | 523 bool m_drawBuffersSupported; |
| 503 | 524 |
| 504 GLint m_packAlignment; | 525 GLint m_packAlignment; |
| 505 GLint m_unpackAlignment; | 526 GLint m_unpackAlignment; |
| 506 bool m_unpackFlipY; | 527 bool m_unpackFlipY; |
| 507 bool m_unpackPremultiplyAlpha; | 528 bool m_unpackPremultiplyAlpha; |
| 508 GLenum m_unpackColorspaceConversion; | 529 GLenum m_unpackColorspaceConversion; |
| 509 bool m_contextLost; | 530 bool m_contextLost; |
| 510 LostContextMode m_contextLostMode; | 531 LostContextMode m_contextLostMode; |
| 511 RefPtr<WebGLContextAttributes> m_requestedAttributes; | 532 RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes; |
| 512 | 533 |
| 513 bool m_layerCleared; | 534 bool m_layerCleared; |
| 514 GLfloat m_clearColor[4]; | 535 GLfloat m_clearColor[4]; |
| 515 bool m_scissorEnabled; | 536 bool m_scissorEnabled; |
| 516 GLfloat m_clearDepth; | 537 GLfloat m_clearDepth; |
| 517 GLint m_clearStencil; | 538 GLint m_clearStencil; |
| 518 GLboolean m_colorMask[4]; | 539 GLboolean m_colorMask[4]; |
| 519 GLboolean m_depthMask; | 540 GLboolean m_depthMask; |
| 520 | 541 |
| 521 bool m_stencilEnabled; | 542 bool m_stencilEnabled; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 538 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 559 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 539 | 560 |
| 540 bool m_savingImage; | 561 bool m_savingImage; |
| 541 | 562 |
| 542 enum ExtensionFlags { | 563 enum ExtensionFlags { |
| 543 ApprovedExtension = 0x00, | 564 ApprovedExtension = 0x00, |
| 544 // Extension that is behind the draft extensions runtime flag: | 565 // Extension that is behind the draft extensions runtime flag: |
| 545 DraftExtension = 0x01, | 566 DraftExtension = 0x01, |
| 546 }; | 567 }; |
| 547 | 568 |
| 548 class ExtensionTracker { | 569 class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracke r> { |
| 549 public: | 570 public: |
| 550 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) | 571 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) |
| 551 : m_draft(flags & DraftExtension) | 572 : m_draft(flags & DraftExtension) |
| 552 , m_prefixes(prefixes) | 573 , m_prefixes(prefixes) |
| 553 { | 574 { |
| 554 } | 575 } |
| 555 | 576 |
| 577 #if !ENABLE(OILPAN) | |
| 556 virtual ~ExtensionTracker() | 578 virtual ~ExtensionTracker() |
| 557 { | 579 { |
| 558 } | 580 } |
| 581 #endif | |
| 559 | 582 |
| 560 bool draft() const | 583 bool draft() const |
| 561 { | 584 { |
| 562 return m_draft; | 585 return m_draft; |
| 563 } | 586 } |
| 564 | 587 |
| 565 const char* const* prefixes() const; | 588 const char* const* prefixes() const; |
| 566 bool matchesNameWithPrefixes(const String&) const; | 589 bool matchesNameWithPrefixes(const String&) const; |
| 567 | 590 |
| 568 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e*) = 0; | 591 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase*) = 0; |
| 569 virtual bool supported(WebGLRenderingContextBase*) const = 0; | 592 virtual bool supported(WebGLRenderingContextBase*) const = 0; |
| 570 virtual const char* extensionName() const = 0; | 593 virtual const char* extensionName() const = 0; |
| 571 virtual void loseExtension() = 0; | 594 virtual void loseExtension() = 0; |
| 572 | 595 |
| 596 virtual void trace(Visitor*) { } | |
| 597 | |
| 573 private: | 598 private: |
| 574 bool m_draft; | 599 bool m_draft; |
| 575 const char* const* m_prefixes; | 600 const char* const* m_prefixes; |
| 576 }; | 601 }; |
| 577 | 602 |
| 578 template <typename T> | 603 template <typename T> |
| 579 class TypedExtensionTracker FINAL : public ExtensionTracker { | 604 class TypedExtensionTracker FINAL : public ExtensionTracker { |
| 580 public: | 605 public: |
| 581 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes) | 606 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 { | 607 { |
| 608 return adoptPtrWillBeNoop(new TypedExtensionTracker<T>(extensionFiel d, flags, prefixes)); | |
| 586 } | 609 } |
| 587 | 610 |
| 611 #if !ENABLE(OILPAN) | |
| 588 virtual ~TypedExtensionTracker() | 612 virtual ~TypedExtensionTracker() |
| 589 { | 613 { |
| 590 if (m_extension) { | 614 if (m_extension) { |
| 591 m_extension->lose(true); | 615 m_extension->lose(true); |
| 592 m_extension = nullptr; | 616 m_extension = nullptr; |
| 593 } | 617 } |
| 594 } | 618 } |
| 619 #endif | |
| 595 | 620 |
| 596 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e* context) OVERRIDE | 621 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase* context) OVERRIDE |
| 597 { | 622 { |
| 598 if (!m_extension) { | 623 if (!m_extension) { |
| 599 m_extension = T::create(context); | 624 m_extension = T::create(context); |
| 600 m_extensionField = m_extension; | 625 m_extensionField = m_extension; |
| 601 } | 626 } |
| 602 | 627 |
| 603 return m_extension; | 628 return m_extension; |
| 604 } | 629 } |
| 605 | 630 |
| 606 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E | 631 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E |
| 607 { | 632 { |
| 608 return T::supported(context); | 633 return T::supported(context); |
| 609 } | 634 } |
| 610 | 635 |
| 611 virtual const char* extensionName() const OVERRIDE | 636 virtual const char* extensionName() const OVERRIDE |
| 612 { | 637 { |
| 613 return T::extensionName(); | 638 return T::extensionName(); |
| 614 } | 639 } |
| 615 | 640 |
| 616 virtual void loseExtension() OVERRIDE | 641 virtual void loseExtension() OVERRIDE |
| 617 { | 642 { |
| 618 if (m_extension) { | 643 if (m_extension) { |
| 619 m_extension->lose(false); | 644 m_extension->lose(false); |
| 620 if (m_extension->isLost()) | 645 if (m_extension->isLost()) |
| 621 m_extension = nullptr; | 646 m_extension = nullptr; |
| 622 } | 647 } |
| 623 } | 648 } |
| 624 | 649 |
| 650 virtual void trace(Visitor* visitor) OVERRIDE | |
| 651 { | |
| 652 visitor->trace(m_extension); | |
| 653 visitor->trace(m_extensionField); | |
| 654 ExtensionTracker::trace(visitor); | |
| 655 } | |
| 656 | |
| 625 private: | 657 private: |
| 626 RefPtr<T>& m_extensionField; | 658 TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFl ags flags, const char* const* prefixes) |
| 659 : ExtensionTracker(flags, prefixes) | |
| 660 , m_extensionField(extensionField) | |
| 661 { | |
| 662 } | |
| 663 | |
| 664 RefPtrWillBeMember<T>& m_extensionField; | |
| 627 // ExtensionTracker holds it's own reference to the extension to ensure | 665 // ExtensionTracker holds it's own reference to the extension to ensure |
| 628 // that it is not deleted before this object's destructor is called | 666 // that it is not deleted before this object's destructor is called |
|
Ken Russell (switch to Gerrit)
2014/07/19 00:27:16
Given that the ExtensionTracker will be garbage-co
sof
2014/07/19 19:55:57
The comment could be rephrased later in more Oilpa
| |
| 629 RefPtr<T> m_extension; | 667 RefPtrWillBeMember<T> m_extension; |
| 630 }; | 668 }; |
| 631 | 669 |
| 632 bool m_extensionEnabled[WebGLExtensionNameCount]; | 670 bool m_extensionEnabled[WebGLExtensionNameCount]; |
| 633 Vector<ExtensionTracker*> m_extensions; | 671 WillBeHeapVector<OwnPtrWillBeMember<ExtensionTracker> > m_extensions; |
| 634 | 672 |
| 635 template <typename T> | 673 template <typename T> |
| 636 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char* const* prefixes = 0) | 674 void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags f lags = ApprovedExtension, const char* const* prefixes = 0) |
| 637 { | 675 { |
| 638 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes)); | 676 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags , prefixes)); |
| 639 } | 677 } |
| 640 | 678 |
| 641 bool extensionSupportedAndAllowed(const ExtensionTracker*); | 679 bool extensionSupportedAndAllowed(const ExtensionTracker*); |
| 642 | 680 |
| 643 inline bool extensionEnabled(WebGLExtensionName name) | 681 inline bool extensionEnabled(WebGLExtensionName name) |
| 644 { | 682 { |
| 645 return m_extensionEnabled[name]; | 683 return m_extensionEnabled[name]; |
| 646 } | 684 } |
| 647 | 685 |
| 648 // Errors raised by synthesizeGLError() while the context is lost. | 686 // 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. | 940 // 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. | 941 // If the vector is empty, return the maximum allowed active context number. |
| 904 static size_t oldestContextIndex(); | 942 static size_t oldestContextIndex(); |
| 905 static IntSize oldestContextSize(); | 943 static IntSize oldestContextSize(); |
| 906 }; | 944 }; |
| 907 | 945 |
| 908 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); | 946 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); |
| 909 | 947 |
| 910 } // namespace WebCore | 948 } // namespace WebCore |
| 911 | 949 |
| 950 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(WebCore::WebGLRenderingContex tBase::TextureUnitState); | |
| 951 | |
| 912 #endif // WebGLRenderingContextBase_h | 952 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |