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

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: Complete VectorTraits<> specialization for VertexAttribState 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void clearStencil(GLint); 139 void clearStencil(GLint);
140 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha); 140 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha);
141 void compileShader(WebGLShader*); 141 void compileShader(WebGLShader*);
142 142
143 void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data); 143 void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data);
144 void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin t yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data); 144 void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin t yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data);
145 145
146 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); 146 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
147 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLint x, GLint y, GLsizei width, GLsizei height); 147 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLint x, GLint y, GLsizei width, GLsizei height);
148 148
149 PassRefPtr<WebGLBuffer> createBuffer(); 149 PassRefPtrWillBeRawPtr<WebGLBuffer> createBuffer();
150 PassRefPtr<WebGLFramebuffer> createFramebuffer(); 150 PassRefPtrWillBeRawPtr<WebGLFramebuffer> createFramebuffer();
151 PassRefPtr<WebGLProgram> createProgram(); 151 PassRefPtrWillBeRawPtr<WebGLProgram> createProgram();
152 PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); 152 PassRefPtrWillBeRawPtr<WebGLRenderbuffer> createRenderbuffer();
153 PassRefPtr<WebGLShader> createShader(GLenum type); 153 PassRefPtrWillBeRawPtr<WebGLShader> createShader(GLenum type);
154 PassRefPtr<WebGLTexture> createTexture(); 154 PassRefPtrWillBeRawPtr<WebGLTexture> createTexture();
155 155
156 void cullFace(GLenum mode); 156 void cullFace(GLenum mode);
157 157
158 void deleteBuffer(WebGLBuffer*); 158 void deleteBuffer(WebGLBuffer*);
159 void deleteFramebuffer(WebGLFramebuffer*); 159 void deleteFramebuffer(WebGLFramebuffer*);
160 void deleteProgram(WebGLProgram*); 160 void deleteProgram(WebGLProgram*);
161 void deleteRenderbuffer(WebGLRenderbuffer*); 161 void deleteRenderbuffer(WebGLRenderbuffer*);
162 void deleteShader(WebGLShader*); 162 void deleteShader(WebGLShader*);
163 void deleteTexture(WebGLTexture*); 163 void deleteTexture(WebGLTexture*);
164 164
(...skipping 11 matching lines...) Expand all
176 176
177 void enable(GLenum cap); 177 void enable(GLenum cap);
178 void enableVertexAttribArray(GLuint index); 178 void enableVertexAttribArray(GLuint index);
179 void finish(); 179 void finish();
180 void flush(); 180 void flush();
181 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*); 181 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*);
182 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level); 182 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level);
183 void frontFace(GLenum mode); 183 void frontFace(GLenum mode);
184 void generateMipmap(GLenum target); 184 void generateMipmap(GLenum target);
185 185
186 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index); 186 PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuin t index);
187 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index); 187 PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLui nt index);
188 bool getAttachedShaders(WebGLProgram*, Vector<RefPtr<WebGLShader> >&); 188 bool getAttachedShaders(WebGLProgram*, WillBeHeapVector<RefPtrWillBeMember<W ebGLShader> >&);
189 GLint getAttribLocation(WebGLProgram*, const String& name); 189 GLint getAttribLocation(WebGLProgram*, const String& name);
190 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname); 190 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname);
191 PassRefPtr<WebGLContextAttributes> getContextAttributes(); 191 PassRefPtrWillBeRawPtr<WebGLContextAttributes> getContextAttributes();
192 GLenum getError(); 192 GLenum getError();
193 PassRefPtr<WebGLExtension> getExtension(const String& name); 193 PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(const String& name);
194 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname); 194 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname);
195 WebGLGetInfo getParameter(GLenum pname); 195 WebGLGetInfo getParameter(GLenum pname);
196 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname); 196 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname);
197 String getProgramInfoLog(WebGLProgram*); 197 String getProgramInfoLog(WebGLProgram*);
198 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname); 198 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname);
199 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname); 199 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname);
200 String getShaderInfoLog(WebGLShader*); 200 String getShaderInfoLog(WebGLShader*);
201 PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shade rType, GLenum precisionType); 201 PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat( GLenum shaderType, GLenum precisionType);
202 String getShaderSource(WebGLShader*); 202 String getShaderSource(WebGLShader*);
203 Vector<String> getSupportedExtensions(); 203 Vector<String> getSupportedExtensions();
204 WebGLGetInfo getTexParameter(GLenum target, GLenum pname); 204 WebGLGetInfo getTexParameter(GLenum target, GLenum pname);
205 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*); 205 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*);
206 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const Str ing&); 206 PassRefPtrWillBeRawPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram *, const String&);
207 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname); 207 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname);
208 long long getVertexAttribOffset(GLuint index, GLenum pname); 208 long long getVertexAttribOffset(GLuint index, GLenum pname);
209 209
210 void hint(GLenum target, GLenum mode); 210 void hint(GLenum target, GLenum mode);
211 GLboolean isBuffer(WebGLBuffer*); 211 GLboolean isBuffer(WebGLBuffer*);
212 bool isContextLost() const; 212 bool isContextLost() const;
213 GLboolean isEnabled(GLenum cap); 213 GLboolean isEnabled(GLenum cap);
214 GLboolean isFramebuffer(WebGLFramebuffer*); 214 GLboolean isFramebuffer(WebGLFramebuffer*);
215 GLboolean isProgram(WebGLProgram*); 215 GLboolean isProgram(WebGLProgram*);
216 GLboolean isRenderbuffer(WebGLRenderbuffer*); 216 GLboolean isRenderbuffer(WebGLRenderbuffer*);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void removeSharedObject(WebGLSharedObject*); 342 void removeSharedObject(WebGLSharedObject*);
343 void removeContextObject(WebGLContextObject*); 343 void removeContextObject(WebGLContextObject*);
344 344
345 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } 345 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; }
346 346
347 // ActiveDOMObject notifications 347 // ActiveDOMObject notifications
348 virtual bool hasPendingActivity() const OVERRIDE; 348 virtual bool hasPendingActivity() const OVERRIDE;
349 virtual void stop() OVERRIDE; 349 virtual void stop() OVERRIDE;
350 350
351 void setSavingImage(bool isSaving) { m_savingImage = isSaving; } 351 void setSavingImage(bool isSaving) { m_savingImage = isSaving; }
352
353 virtual void trace(Visitor*) OVERRIDE;
354
355 class TextureUnitState {
356 ALLOW_ONLY_INLINE_ALLOCATION();
357 public:
358 RefPtrWillBeMember<WebGLTexture> m_texture2DBinding;
359 RefPtrWillBeMember<WebGLTexture> m_textureCubeMapBinding;
360
361 void trace(Visitor*);
362 };
363
352 protected: 364 protected:
353 friend class WebGLDrawBuffers; 365 friend class WebGLDrawBuffers;
354 friend class WebGLFramebuffer; 366 friend class WebGLFramebuffer;
355 friend class WebGLObject; 367 friend class WebGLObject;
356 friend class OESVertexArrayObject; 368 friend class OESVertexArrayObject;
357 friend class WebGLDebugShaders; 369 friend class WebGLDebugShaders;
358 friend class WebGLCompressedTextureATC; 370 friend class WebGLCompressedTextureATC;
359 friend class WebGLCompressedTextureETC1; 371 friend class WebGLCompressedTextureETC1;
360 friend class WebGLCompressedTexturePVRTC; 372 friend class WebGLCompressedTexturePVRTC;
361 friend class WebGLCompressedTextureS3TC; 373 friend class WebGLCompressedTextureS3TC;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 407
396 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const c har* functionName); 408 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const c har* functionName);
397 409
398 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); 410 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy);
399 411
400 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*); 412 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*);
401 413
402 // Structure for rendering to a DrawingBuffer, instead of directly 414 // Structure for rendering to a DrawingBuffer, instead of directly
403 // to the back-buffer of m_context. 415 // to the back-buffer of m_context.
404 RefPtr<DrawingBuffer> m_drawingBuffer; 416 RefPtr<DrawingBuffer> m_drawingBuffer;
405 RefPtr<WebGLContextGroup> m_contextGroup; 417 RefPtrWillBeMember<WebGLContextGroup> m_contextGroup;
406 418
407 // Dispatches a context lost event once it is determined that one is needed. 419 // Dispatches a context lost event once it is determined that one is needed.
408 // This is used both for synthetic and real context losses. For real ones, i t's 420 // This is used both for synthetic and real context losses. For real ones, i t's
409 // likely that there's no JavaScript on the stack, but that might be depende nt 421 // likely that there's no JavaScript on the stack, but that might be depende nt
410 // on how exactly the platform discovers that the context was lost. For bett er 422 // on how exactly the platform discovers that the context was lost. For bett er
411 // portability we always defer the dispatch of the event. 423 // portability we always defer the dispatch of the event.
412 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; 424 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
413 bool m_restoreAllowed; 425 bool m_restoreAllowed;
414 Timer<WebGLRenderingContextBase> m_restoreTimer; 426 Timer<WebGLRenderingContextBase> m_restoreTimer;
415 427
416 bool m_needsUpdate; 428 bool m_needsUpdate;
417 bool m_markedCanvasDirty; 429 bool m_markedCanvasDirty;
418 HashSet<WebGLContextObject*> m_contextObjects; 430 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObje cts;
419 431
420 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; 432 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter;
421 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter; 433 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter;
422 434
423 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER 435 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER
424 RefPtr<WebGLBuffer> m_boundArrayBuffer; 436 RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer;
425 437
426 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; 438 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
427 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; 439 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
428 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayOb ject) 440 void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObject OES> arrayObject)
429 { 441 {
430 if (arrayObject) 442 if (arrayObject)
431 m_boundVertexArrayObject = arrayObject; 443 m_boundVertexArrayObject = arrayObject;
432 else 444 else
433 m_boundVertexArrayObject = m_defaultVertexArrayObject; 445 m_boundVertexArrayObject = m_defaultVertexArrayObject;
434 } 446 }
435 447
436 class VertexAttribValue { 448 class VertexAttribValue {
437 public: 449 public:
438 VertexAttribValue() 450 VertexAttribValue()
439 { 451 {
440 initValue(); 452 initValue();
441 } 453 }
442 454
443 void initValue() 455 void initValue()
444 { 456 {
445 value[0] = 0.0f; 457 value[0] = 0.0f;
446 value[1] = 0.0f; 458 value[1] = 0.0f;
447 value[2] = 0.0f; 459 value[2] = 0.0f;
448 value[3] = 1.0f; 460 value[3] = 1.0f;
449 } 461 }
450 462
451 GLfloat value[4]; 463 GLfloat value[4];
452 }; 464 };
453 Vector<VertexAttribValue> m_vertexAttribValue; 465 Vector<VertexAttribValue> m_vertexAttribValue;
454 unsigned m_maxVertexAttribs; 466 unsigned m_maxVertexAttribs;
455 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; 467 RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer;
456 long m_vertexAttrib0BufferSize; 468 long m_vertexAttrib0BufferSize;
457 GLfloat m_vertexAttrib0BufferValue[4]; 469 GLfloat m_vertexAttrib0BufferValue[4];
458 bool m_forceAttrib0BufferRefill; 470 bool m_forceAttrib0BufferRefill;
459 bool m_vertexAttrib0UsedBefore; 471 bool m_vertexAttrib0UsedBefore;
460 472
461 RefPtr<WebGLProgram> m_currentProgram; 473 RefPtrWillBeMember<WebGLProgram> m_currentProgram;
462 RefPtr<WebGLFramebuffer> m_framebufferBinding; 474 RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding;
463 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; 475 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding;
464 class TextureUnitState { 476
465 public: 477 WillBeHeapVector<TextureUnitState> m_textureUnits;
466 RefPtr<WebGLTexture> m_texture2DBinding;
467 RefPtr<WebGLTexture> m_textureCubeMapBinding;
468 };
469 Vector<TextureUnitState> m_textureUnits;
470 unsigned long m_activeTextureUnit; 478 unsigned long m_activeTextureUnit;
471 479
472 RefPtr<WebGLTexture> m_blackTexture2D; 480 RefPtrWillBeMember<WebGLTexture> m_blackTexture2D;
473 RefPtr<WebGLTexture> m_blackTextureCubeMap; 481 RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap;
474 482
475 Vector<GLenum> m_compressedTextureFormats; 483 Vector<GLenum> m_compressedTextureFormats;
476 484
477 // Fixed-size cache of reusable image buffers for video texImage2D calls. 485 // Fixed-size cache of reusable image buffers for video texImage2D calls.
478 class LRUImageBufferCache { 486 class LRUImageBufferCache {
479 public: 487 public:
480 LRUImageBufferCache(int capacity); 488 LRUImageBufferCache(int capacity);
481 // The pointer returned is owned by the image buffer map. 489 // The pointer returned is owned by the image buffer map.
482 ImageBuffer* imageBuffer(const IntSize& size); 490 ImageBuffer* imageBuffer(const IntSize& size);
483 private: 491 private:
(...skipping 16 matching lines...) Expand all
500 bool m_drawBuffersWebGLRequirementsChecked; 508 bool m_drawBuffersWebGLRequirementsChecked;
501 bool m_drawBuffersSupported; 509 bool m_drawBuffersSupported;
502 510
503 GLint m_packAlignment; 511 GLint m_packAlignment;
504 GLint m_unpackAlignment; 512 GLint m_unpackAlignment;
505 bool m_unpackFlipY; 513 bool m_unpackFlipY;
506 bool m_unpackPremultiplyAlpha; 514 bool m_unpackPremultiplyAlpha;
507 GLenum m_unpackColorspaceConversion; 515 GLenum m_unpackColorspaceConversion;
508 bool m_contextLost; 516 bool m_contextLost;
509 LostContextMode m_contextLostMode; 517 LostContextMode m_contextLostMode;
510 RefPtr<WebGLContextAttributes> m_requestedAttributes; 518 RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes;
511 519
512 bool m_layerCleared; 520 bool m_layerCleared;
513 GLfloat m_clearColor[4]; 521 GLfloat m_clearColor[4];
514 bool m_scissorEnabled; 522 bool m_scissorEnabled;
515 GLfloat m_clearDepth; 523 GLfloat m_clearDepth;
516 GLint m_clearStencil; 524 GLint m_clearStencil;
517 GLboolean m_colorMask[4]; 525 GLboolean m_colorMask[4];
518 GLboolean m_depthMask; 526 GLboolean m_depthMask;
519 527
520 bool m_stencilEnabled; 528 bool m_stencilEnabled;
(...skipping 16 matching lines...) Expand all
537 OwnPtr<Extensions3DUtil> m_extensionsUtil; 545 OwnPtr<Extensions3DUtil> m_extensionsUtil;
538 546
539 bool m_savingImage; 547 bool m_savingImage;
540 548
541 enum ExtensionFlags { 549 enum ExtensionFlags {
542 ApprovedExtension = 0x00, 550 ApprovedExtension = 0x00,
543 // Extension that is behind the draft extensions runtime flag: 551 // Extension that is behind the draft extensions runtime flag:
544 DraftExtension = 0x01, 552 DraftExtension = 0x01,
545 }; 553 };
546 554
547 class ExtensionTracker { 555 class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracke r> {
548 public: 556 public:
549 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) 557 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes)
550 : m_draft(flags & DraftExtension) 558 : m_draft(flags & DraftExtension)
551 , m_prefixes(prefixes) 559 , m_prefixes(prefixes)
552 { 560 {
553 } 561 }
554 562
563 #if !ENABLE(OILPAN)
555 virtual ~ExtensionTracker() 564 virtual ~ExtensionTracker()
556 { 565 {
557 } 566 }
567 #endif
558 568
559 bool draft() const 569 bool draft() const
560 { 570 {
561 return m_draft; 571 return m_draft;
562 } 572 }
563 573
564 const char* const* prefixes() const; 574 const char* const* prefixes() const;
565 bool matchesNameWithPrefixes(const String&) const; 575 bool matchesNameWithPrefixes(const String&) const;
566 576
567 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e*) = 0; 577 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase*) = 0;
568 virtual bool supported(WebGLRenderingContextBase*) const = 0; 578 virtual bool supported(WebGLRenderingContextBase*) const = 0;
569 virtual const char* extensionName() const = 0; 579 virtual const char* extensionName() const = 0;
570 virtual void loseExtension() = 0; 580 virtual void loseExtension() = 0;
571 581
582 virtual void trace(Visitor*) { }
583
572 private: 584 private:
573 bool m_draft; 585 bool m_draft;
574 const char* const* m_prefixes; 586 const char* const* m_prefixes;
575 }; 587 };
576 588
577 template <typename T> 589 template <typename T>
578 class TypedExtensionTracker FINAL : public ExtensionTracker { 590 class TypedExtensionTracker FINAL : public ExtensionTracker {
579 public: 591 public:
580 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes) 592 TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFl ags flags, const char* const* prefixes)
581 : ExtensionTracker(flags, prefixes) 593 : ExtensionTracker(flags, prefixes)
582 , m_extensionField(extensionField) 594 , m_extensionField(extensionField)
583 , m_extension(nullptr) 595 , m_extension(nullptr)
584 { 596 {
585 } 597 }
586 598
599 #if !ENABLE(OILPAN)
587 virtual ~TypedExtensionTracker() 600 virtual ~TypedExtensionTracker()
588 { 601 {
589 if (m_extension) { 602 if (m_extension) {
590 m_extension->lose(true); 603 m_extension->lose(true);
591 m_extension = nullptr; 604 m_extension = nullptr;
592 } 605 }
593 } 606 }
607 #endif
594 608
595 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e* context) OVERRIDE 609 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase* context) OVERRIDE
596 { 610 {
597 if (!m_extension) { 611 if (!m_extension) {
598 m_extension = T::create(context); 612 m_extension = T::create(context);
599 m_extensionField = m_extension; 613 m_extensionField = m_extension;
600 } 614 }
601 615
602 return m_extension; 616 return m_extension;
603 } 617 }
604 618
605 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E 619 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E
606 { 620 {
607 return T::supported(context); 621 return T::supported(context);
608 } 622 }
609 623
610 virtual const char* extensionName() const OVERRIDE 624 virtual const char* extensionName() const OVERRIDE
611 { 625 {
612 return T::extensionName(); 626 return T::extensionName();
613 } 627 }
614 628
615 virtual void loseExtension() OVERRIDE 629 virtual void loseExtension() OVERRIDE
616 { 630 {
617 if (m_extension) { 631 if (m_extension) {
618 m_extension->lose(false); 632 m_extension->lose(false);
619 if (m_extension->isLost()) 633 if (m_extension->isLost())
620 m_extension = nullptr; 634 m_extension = nullptr;
621 } 635 }
622 } 636 }
623 637
638 virtual void trace(Visitor* visitor) OVERRIDE
639 {
640 visitor->trace(m_extensionField);
641 visitor->trace(m_extension);
642 ExtensionTracker::trace(visitor);
643 }
644
624 private: 645 private:
625 RefPtr<T>& m_extensionField; 646 RefPtrWillBeMember<T>& m_extensionField;
haraken 2014/07/02 07:47:39 It looks weird to use RefPtrWillBeMember<T>&... E
sof 2014/07/02 11:43:53 Dropped tracing off it; I don't see a ready way ar
626 // ExtensionTracker holds it's own reference to the extension to ensure 647 // ExtensionTracker holds it's own reference to the extension to ensure
627 // that it is not deleted before this object's destructor is called 648 // that it is not deleted before this object's destructor is called
628 RefPtr<T> m_extension; 649 RefPtrWillBeMember<T> m_extension;
629 }; 650 };
630 651
631 bool m_extensionEnabled[WebGLExtensionNameCount]; 652 bool m_extensionEnabled[WebGLExtensionNameCount];
632 Vector<ExtensionTracker*> m_extensions; 653 WillBeHeapVector<RawPtrWillBeMember<ExtensionTracker> > m_extensions;
haraken 2014/07/02 07:47:39 Not related to this CL, we should use OwnPtr<Exten
sof 2014/07/02 11:43:53 That would be tidier (and not have to keep them on
633 654
634 template <typename T> 655 template <typename T>
635 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char* const* prefixes = 0) 656 void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags f lags = ApprovedExtension, const char* const* prefixes = 0)
636 { 657 {
637 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes)); 658 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes));
638 } 659 }
639 660
640 bool extensionSupportedAndAllowed(const ExtensionTracker*); 661 bool extensionSupportedAndAllowed(const ExtensionTracker*);
641 662
642 inline bool extensionEnabled(WebGLExtensionName name) 663 inline bool extensionEnabled(WebGLExtensionName name)
643 { 664 {
644 return m_extensionEnabled[name]; 665 return m_extensionEnabled[name];
645 } 666 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // Return the least recently used context's position in the active context v ector. 922 // Return the least recently used context's position in the active context v ector.
902 // If the vector is empty, return the maximum allowed active context number. 923 // If the vector is empty, return the maximum allowed active context number.
903 static size_t oldestContextIndex(); 924 static size_t oldestContextIndex();
904 static IntSize oldestContextSize(); 925 static IntSize oldestContextSize();
905 }; 926 };
906 927
907 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 928 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
908 929
909 } // namespace WebCore 930 } // namespace WebCore
910 931
932 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(WebCore::WebGLRenderingContex tBase::TextureUnitState);
haraken 2014/07/02 07:47:39 Is it safe to move TextureUnitState with memcpy ev
sof 2014/07/02 11:43:53 Yes; under what conditions could a bit-preserving
933
911 #endif // WebGLRenderingContextBase_h 934 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698