Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.h

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Smaller adjustments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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; }
353 355
354 virtual void trace(Visitor* visitor) OVERRIDE { CanvasRenderingContext::trac e(visitor); } 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
355 protected: 367 protected:
356 friend class WebGLDrawBuffers; 368 friend class WebGLDrawBuffers;
357 friend class WebGLFramebuffer; 369 friend class WebGLFramebuffer;
358 friend class WebGLObject; 370 friend class WebGLObject;
371 friend class WebGLContextObject;
359 friend class OESVertexArrayObject; 372 friend class OESVertexArrayObject;
360 friend class WebGLDebugShaders; 373 friend class WebGLDebugShaders;
361 friend class WebGLCompressedTextureATC; 374 friend class WebGLCompressedTextureATC;
362 friend class WebGLCompressedTextureETC1; 375 friend class WebGLCompressedTextureETC1;
363 friend class WebGLCompressedTexturePVRTC; 376 friend class WebGLCompressedTexturePVRTC;
364 friend class WebGLCompressedTextureS3TC; 377 friend class WebGLCompressedTextureS3TC;
365 friend class WebGLRenderingContextErrorMessageCallback; 378 friend class WebGLRenderingContextErrorMessageCallback;
366 friend class WebGLVertexArrayObjectOES; 379 friend class WebGLVertexArrayObjectOES;
367 friend class ScopedTexture2DRestorer; 380 friend class ScopedTexture2DRestorer;
368 381
369 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*); 382 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*);
370 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsC ontext3D>); 383 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsC ontext3D>);
371 void initializeNewContext(); 384 void initializeNewContext();
372 void setupFlags(); 385 void setupFlags();
373 386
387 #if ENABLE(OILPAN)
388 PassRefPtr<WebGLSharedWebGraphicsContext3D> sharedWebGraphicsContext3D() con st;
389 #endif
390
374 void addSharedObject(WebGLSharedObject*); 391 void addSharedObject(WebGLSharedObject*);
375 void addContextObject(WebGLContextObject*); 392 void addContextObject(WebGLContextObject*);
376 void detachAndRemoveAllObjects(); 393 void detachAndRemoveAllObjects();
377 394
378 void destroyContext(); 395 void destroyContext();
379 void markContextChanged(ContentChangeType); 396 void markContextChanged(ContentChangeType);
380 397
381 // Query if the GL implementation is NPOT strict. 398 // Query if the GL implementation is NPOT strict.
382 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } 399 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; }
383 // Query if depth_stencil buffer is supported. 400 // Query if depth_stencil buffer is supported.
(...skipping 13 matching lines...) Expand all
397 void removeAllCompressedTextureFormats(); 414 void removeAllCompressedTextureFormats();
398 415
399 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);
400 417
401 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); 418 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy);
402 419
403 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*); 420 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*);
404 421
405 // Structure for rendering to a DrawingBuffer, instead of directly 422 // Structure for rendering to a DrawingBuffer, instead of directly
406 // 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
407 RefPtr<DrawingBuffer> m_drawingBuffer; 427 RefPtr<DrawingBuffer> m_drawingBuffer;
428 #endif
429 DrawingBuffer* drawingBuffer() const;
430
408 RefPtr<WebGLContextGroup> m_contextGroup; 431 RefPtr<WebGLContextGroup> m_contextGroup;
409 432
410 // 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.
411 // 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
412 // 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
413 // 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
414 // portability we always defer the dispatch of the event. 437 // portability we always defer the dispatch of the event.
415 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; 438 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
416 bool m_restoreAllowed; 439 bool m_restoreAllowed;
417 Timer<WebGLRenderingContextBase> m_restoreTimer; 440 Timer<WebGLRenderingContextBase> m_restoreTimer;
418 441
419 bool m_needsUpdate; 442 bool m_needsUpdate;
420 bool m_markedCanvasDirty; 443 bool m_markedCanvasDirty;
421 HashSet<WebGLContextObject*> m_contextObjects; 444 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObje cts;
422 445
423 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; 446 OwnPtrWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallbackA dapter;
424 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter; 447 OwnPtrWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMessage CallbackAdapter;
425 448
426 // 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
427 RefPtr<WebGLBuffer> m_boundArrayBuffer; 450 RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer;
428 451
429 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; 452 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
430 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; 453 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
431 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayOb ject) 454 void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObject OES> arrayObject)
432 { 455 {
433 if (arrayObject) 456 if (arrayObject)
434 m_boundVertexArrayObject = arrayObject; 457 m_boundVertexArrayObject = arrayObject;
435 else 458 else
436 m_boundVertexArrayObject = m_defaultVertexArrayObject; 459 m_boundVertexArrayObject = m_defaultVertexArrayObject;
437 } 460 }
438 461
439 class VertexAttribValue { 462 class VertexAttribValue {
440 public: 463 public:
441 VertexAttribValue() 464 VertexAttribValue()
442 { 465 {
443 initValue(); 466 initValue();
444 } 467 }
445 468
446 void initValue() 469 void initValue()
447 { 470 {
448 value[0] = 0.0f; 471 value[0] = 0.0f;
449 value[1] = 0.0f; 472 value[1] = 0.0f;
450 value[2] = 0.0f; 473 value[2] = 0.0f;
451 value[3] = 1.0f; 474 value[3] = 1.0f;
452 } 475 }
453 476
454 GLfloat value[4]; 477 GLfloat value[4];
455 }; 478 };
456 Vector<VertexAttribValue> m_vertexAttribValue; 479 Vector<VertexAttribValue> m_vertexAttribValue;
457 unsigned m_maxVertexAttribs; 480 unsigned m_maxVertexAttribs;
458 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; 481 RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer;
459 long m_vertexAttrib0BufferSize; 482 long m_vertexAttrib0BufferSize;
460 GLfloat m_vertexAttrib0BufferValue[4]; 483 GLfloat m_vertexAttrib0BufferValue[4];
461 bool m_forceAttrib0BufferRefill; 484 bool m_forceAttrib0BufferRefill;
462 bool m_vertexAttrib0UsedBefore; 485 bool m_vertexAttrib0UsedBefore;
463 486
464 RefPtr<WebGLProgram> m_currentProgram; 487 RefPtrWillBeMember<WebGLProgram> m_currentProgram;
465 RefPtr<WebGLFramebuffer> m_framebufferBinding; 488 RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding;
466 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; 489 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding;
467 class TextureUnitState { 490
468 public: 491 WillBeHeapVector<TextureUnitState> m_textureUnits;
469 RefPtr<WebGLTexture> m_texture2DBinding;
470 RefPtr<WebGLTexture> m_textureCubeMapBinding;
471 };
472 Vector<TextureUnitState> m_textureUnits;
473 unsigned long m_activeTextureUnit; 492 unsigned long m_activeTextureUnit;
474 493
475 RefPtr<WebGLTexture> m_blackTexture2D; 494 RefPtrWillBeMember<WebGLTexture> m_blackTexture2D;
476 RefPtr<WebGLTexture> m_blackTextureCubeMap; 495 RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap;
477 496
478 Vector<GLenum> m_compressedTextureFormats; 497 Vector<GLenum> m_compressedTextureFormats;
479 498
480 // Fixed-size cache of reusable image buffers for video texImage2D calls. 499 // Fixed-size cache of reusable image buffers for video texImage2D calls.
481 class LRUImageBufferCache { 500 class LRUImageBufferCache {
482 public: 501 public:
483 LRUImageBufferCache(int capacity); 502 LRUImageBufferCache(int capacity);
484 // The pointer returned is owned by the image buffer map. 503 // The pointer returned is owned by the image buffer map.
485 ImageBuffer* imageBuffer(const IntSize& size); 504 ImageBuffer* imageBuffer(const IntSize& size);
486 private: 505 private:
(...skipping 16 matching lines...) Expand all
503 bool m_drawBuffersWebGLRequirementsChecked; 522 bool m_drawBuffersWebGLRequirementsChecked;
504 bool m_drawBuffersSupported; 523 bool m_drawBuffersSupported;
505 524
506 GLint m_packAlignment; 525 GLint m_packAlignment;
507 GLint m_unpackAlignment; 526 GLint m_unpackAlignment;
508 bool m_unpackFlipY; 527 bool m_unpackFlipY;
509 bool m_unpackPremultiplyAlpha; 528 bool m_unpackPremultiplyAlpha;
510 GLenum m_unpackColorspaceConversion; 529 GLenum m_unpackColorspaceConversion;
511 bool m_contextLost; 530 bool m_contextLost;
512 LostContextMode m_contextLostMode; 531 LostContextMode m_contextLostMode;
513 RefPtr<WebGLContextAttributes> m_requestedAttributes; 532 RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes;
514 533
515 bool m_layerCleared; 534 bool m_layerCleared;
516 GLfloat m_clearColor[4]; 535 GLfloat m_clearColor[4];
517 bool m_scissorEnabled; 536 bool m_scissorEnabled;
518 GLfloat m_clearDepth; 537 GLfloat m_clearDepth;
519 GLint m_clearStencil; 538 GLint m_clearStencil;
520 GLboolean m_colorMask[4]; 539 GLboolean m_colorMask[4];
521 GLboolean m_depthMask; 540 GLboolean m_depthMask;
522 541
523 bool m_stencilEnabled; 542 bool m_stencilEnabled;
(...skipping 16 matching lines...) Expand all
540 OwnPtr<Extensions3DUtil> m_extensionsUtil; 559 OwnPtr<Extensions3DUtil> m_extensionsUtil;
541 560
542 bool m_savingImage; 561 bool m_savingImage;
543 562
544 enum ExtensionFlags { 563 enum ExtensionFlags {
545 ApprovedExtension = 0x00, 564 ApprovedExtension = 0x00,
546 // Extension that is behind the draft extensions runtime flag: 565 // Extension that is behind the draft extensions runtime flag:
547 DraftExtension = 0x01, 566 DraftExtension = 0x01,
548 }; 567 };
549 568
550 class ExtensionTracker { 569 class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracke r> {
551 public: 570 public:
552 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) 571 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes)
553 : m_draft(flags & DraftExtension) 572 : m_draft(flags & DraftExtension)
554 , m_prefixes(prefixes) 573 , m_prefixes(prefixes)
555 { 574 {
556 } 575 }
557 576
577 #if !ENABLE(OILPAN)
558 virtual ~ExtensionTracker() 578 virtual ~ExtensionTracker()
559 { 579 {
560 } 580 }
581 #endif
561 582
562 bool draft() const 583 bool draft() const
563 { 584 {
564 return m_draft; 585 return m_draft;
565 } 586 }
566 587
567 const char* const* prefixes() const; 588 const char* const* prefixes() const;
568 bool matchesNameWithPrefixes(const String&) const; 589 bool matchesNameWithPrefixes(const String&) const;
569 590
570 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e*) = 0; 591 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase*) = 0;
571 virtual bool supported(WebGLRenderingContextBase*) const = 0; 592 virtual bool supported(WebGLRenderingContextBase*) const = 0;
572 virtual const char* extensionName() const = 0; 593 virtual const char* extensionName() const = 0;
573 virtual void loseExtension() = 0; 594 virtual void loseExtension() = 0;
574 595
596 virtual void trace(Visitor*) { }
597
575 private: 598 private:
576 bool m_draft; 599 bool m_draft;
577 const char* const* m_prefixes; 600 const char* const* m_prefixes;
578 }; 601 };
579 602
580 template <typename T> 603 template <typename T>
581 class TypedExtensionTracker FINAL : public ExtensionTracker { 604 class TypedExtensionTracker FINAL : public ExtensionTracker {
582 public: 605 public:
583 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 )
584 : ExtensionTracker(flags, prefixes)
585 , m_extensionField(extensionField)
586 , m_extension(nullptr)
587 { 607 {
608 return adoptPtrWillBeNoop(new TypedExtensionTracker<T>(extensionFiel d, flags, prefixes));
588 } 609 }
589 610
611 #if !ENABLE(OILPAN)
590 virtual ~TypedExtensionTracker() 612 virtual ~TypedExtensionTracker()
591 { 613 {
592 if (m_extension) { 614 if (m_extension) {
593 m_extension->lose(true); 615 m_extension->lose(true);
594 m_extension = nullptr; 616 m_extension = nullptr;
595 } 617 }
596 } 618 }
619 #endif
597 620
598 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e* context) OVERRIDE 621 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase* context) OVERRIDE
599 { 622 {
600 if (!m_extension) { 623 if (!m_extension) {
601 m_extension = T::create(context); 624 m_extension = T::create(context);
602 m_extensionField = m_extension; 625 m_extensionField = m_extension;
603 } 626 }
604 627
605 return m_extension; 628 return m_extension;
606 } 629 }
607 630
608 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E 631 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E
609 { 632 {
610 return T::supported(context); 633 return T::supported(context);
611 } 634 }
612 635
613 virtual const char* extensionName() const OVERRIDE 636 virtual const char* extensionName() const OVERRIDE
614 { 637 {
615 return T::extensionName(); 638 return T::extensionName();
616 } 639 }
617 640
618 virtual void loseExtension() OVERRIDE 641 virtual void loseExtension() OVERRIDE
619 { 642 {
620 if (m_extension) { 643 if (m_extension) {
621 m_extension->lose(false); 644 m_extension->lose(false);
622 if (m_extension->isLost()) 645 if (m_extension->isLost())
623 m_extension = nullptr; 646 m_extension = nullptr;
624 } 647 }
625 } 648 }
626 649
650 virtual void trace(Visitor* visitor) OVERRIDE
651 {
652 visitor->trace(m_extension);
653 ExtensionTracker::trace(visitor);
654 }
655
627 private: 656 private:
628 RefPtr<T>& m_extensionField; 657 TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFl ags flags, const char* const* prefixes)
658 : ExtensionTracker(flags, prefixes)
659 , m_extensionField(extensionField)
660 {
661 }
662
663 RefPtrWillBeMember<T>& m_extensionField;
629 // ExtensionTracker holds it's own reference to the extension to ensure 664 // ExtensionTracker holds it's own reference to the extension to ensure
630 // that it is not deleted before this object's destructor is called 665 // that it is not deleted before this object's destructor is called
631 RefPtr<T> m_extension; 666 RefPtrWillBeMember<T> m_extension;
632 }; 667 };
633 668
634 bool m_extensionEnabled[WebGLExtensionNameCount]; 669 bool m_extensionEnabled[WebGLExtensionNameCount];
635 Vector<ExtensionTracker*> m_extensions; 670 WillBeHeapVector<OwnPtrWillBeMember<ExtensionTracker> > m_extensions;
636 671
637 template <typename T> 672 template <typename T>
638 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char* const* prefixes = 0) 673 void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags f lags = ApprovedExtension, const char* const* prefixes = 0)
639 { 674 {
640 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes)); 675 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags , prefixes));
641 } 676 }
642 677
643 bool extensionSupportedAndAllowed(const ExtensionTracker*); 678 bool extensionSupportedAndAllowed(const ExtensionTracker*);
644 679
645 inline bool extensionEnabled(WebGLExtensionName name) 680 inline bool extensionEnabled(WebGLExtensionName name)
646 { 681 {
647 return m_extensionEnabled[name]; 682 return m_extensionEnabled[name];
648 } 683 }
649 684
650 // Errors raised by synthesizeGLError() while the context is lost. 685 // Errors raised by synthesizeGLError() while the context is lost.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 // Return the least recently used context's position in the active context v ector. 939 // Return the least recently used context's position in the active context v ector.
905 // If the vector is empty, return the maximum allowed active context number. 940 // If the vector is empty, return the maximum allowed active context number.
906 static size_t oldestContextIndex(); 941 static size_t oldestContextIndex();
907 static IntSize oldestContextSize(); 942 static IntSize oldestContextSize();
908 }; 943 };
909 944
910 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 945 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
911 946
912 } // namespace blink 947 } // namespace blink
913 948
949 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(WebCore::WebGLRenderingContex tBase::TextureUnitState);
950
914 #endif // WebGLRenderingContextBase_h 951 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698