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

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: Rebased + Nullable<traceable-value> workaround 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 class WebGLShader; 91 class WebGLShader;
92 class WebGLShaderPrecisionFormat; 92 class WebGLShaderPrecisionFormat;
93 class WebGLSharedObject; 93 class WebGLSharedObject;
94 class WebGLTexture; 94 class WebGLTexture;
95 class WebGLUniformLocation; 95 class WebGLUniformLocation;
96 class WebGLVertexArrayObjectOES; 96 class WebGLVertexArrayObjectOES;
97 97
98 class WebGLRenderingContextLostCallback; 98 class WebGLRenderingContextLostCallback;
99 class WebGLRenderingContextErrorMessageCallback; 99 class WebGLRenderingContextErrorMessageCallback;
100 100
101
102 #if ENABLE(OILPAN)
103 // The finalization of the attached WebGLContextObjects is done with respect to the
104 // blink::WebGraphicsContext3D object of this object's DrawingBuffer.
105 // With Oilpan, we need to keep this DrawingBuffer (=> its blink::WebGraphicsCon text3D)
106 // alive until all such finalizers have run. Make the WebGLContextObjects keep
107 // a RefPtr to an off-heap object that handles the eventual release of the
108 // underlying DrawingBuffer when all the finalizers have run.
109 //
110 // FIXME: move this into header + implementation files of its own once settled.
111 class WebGLSharedWebGraphicsContext3D FINAL : public RefCounted<WebGLSharedWebGr aphicsContext3D> {
112 public:
113 static PassRefPtr<WebGLSharedWebGraphicsContext3D> create(PassRefPtr<Drawing Buffer>);
114
115 ~WebGLSharedWebGraphicsContext3D();
116
117 void reset();
118 void update(PassRefPtr<DrawingBuffer>);
119
120 blink::WebGraphicsContext3D* webContext() { return m_buffer ? m_buffer->cont ext() : 0; }
121 private:
122 explicit WebGLSharedWebGraphicsContext3D(PassRefPtr<DrawingBuffer>);
123
124 RefPtr<DrawingBuffer> m_buffer;
125 };
126 #endif
127
101 class WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOM Object, public Page::MultisamplingChangedObserver { 128 class WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOM Object, public Page::MultisamplingChangedObserver {
102 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); 129 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase);
103 public: 130 public:
104 virtual ~WebGLRenderingContextBase(); 131 virtual ~WebGLRenderingContextBase();
105 132
106 virtual bool is3d() const OVERRIDE { return true; } 133 virtual bool is3d() const OVERRIDE { return true; }
107 virtual bool isAccelerated() const OVERRIDE { return true; } 134 virtual bool isAccelerated() const OVERRIDE { return true; }
108 virtual unsigned version() const = 0; 135 virtual unsigned version() const = 0;
109 virtual String contextName() const = 0; 136 virtual String contextName() const = 0;
110 virtual void registerContextExtensions() = 0; 137 virtual void registerContextExtensions() = 0;
(...skipping 29 matching lines...) Expand all
140 void clearStencil(GLint); 167 void clearStencil(GLint);
141 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha); 168 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha);
142 void compileShader(WebGLShader*); 169 void compileShader(WebGLShader*);
143 170
144 void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data); 171 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); 172 void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin t yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data);
146 173
147 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); 174 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); 175 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLint x, GLint y, GLsizei width, GLsizei height);
149 176
150 PassRefPtr<WebGLBuffer> createBuffer(); 177 PassRefPtrWillBeRawPtr<WebGLBuffer> createBuffer();
151 PassRefPtr<WebGLFramebuffer> createFramebuffer(); 178 PassRefPtrWillBeRawPtr<WebGLFramebuffer> createFramebuffer();
152 PassRefPtr<WebGLProgram> createProgram(); 179 PassRefPtrWillBeRawPtr<WebGLProgram> createProgram();
153 PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); 180 PassRefPtrWillBeRawPtr<WebGLRenderbuffer> createRenderbuffer();
154 PassRefPtr<WebGLShader> createShader(GLenum type); 181 PassRefPtrWillBeRawPtr<WebGLShader> createShader(GLenum type);
155 PassRefPtr<WebGLTexture> createTexture(); 182 PassRefPtrWillBeRawPtr<WebGLTexture> createTexture();
156 183
157 void cullFace(GLenum mode); 184 void cullFace(GLenum mode);
158 185
159 void deleteBuffer(WebGLBuffer*); 186 void deleteBuffer(WebGLBuffer*);
160 void deleteFramebuffer(WebGLFramebuffer*); 187 void deleteFramebuffer(WebGLFramebuffer*);
161 void deleteProgram(WebGLProgram*); 188 void deleteProgram(WebGLProgram*);
162 void deleteRenderbuffer(WebGLRenderbuffer*); 189 void deleteRenderbuffer(WebGLRenderbuffer*);
163 void deleteShader(WebGLShader*); 190 void deleteShader(WebGLShader*);
164 void deleteTexture(WebGLTexture*); 191 void deleteTexture(WebGLTexture*);
165 192
(...skipping 11 matching lines...) Expand all
177 204
178 void enable(GLenum cap); 205 void enable(GLenum cap);
179 void enableVertexAttribArray(GLuint index); 206 void enableVertexAttribArray(GLuint index);
180 void finish(); 207 void finish();
181 void flush(); 208 void flush();
182 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*); 209 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*);
183 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level); 210 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level);
184 void frontFace(GLenum mode); 211 void frontFace(GLenum mode);
185 void generateMipmap(GLenum target); 212 void generateMipmap(GLenum target);
186 213
187 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index); 214 PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuin t index);
188 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index); 215 PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLui nt index);
189 Nullable<Vector<RefPtr<WebGLShader> > > getAttachedShaders(WebGLProgram*); 216 bool getAttachedShaders(WebGLProgram*, WillBeHeapVector<RefPtrWillBeMember<W ebGLShader> >&);
217 Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > > getAttachedSha ders(WebGLProgram*);
190 GLint getAttribLocation(WebGLProgram*, const String& name); 218 GLint getAttribLocation(WebGLProgram*, const String& name);
191 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname); 219 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname);
192 PassRefPtr<WebGLContextAttributes> getContextAttributes(); 220 PassRefPtrWillBeRawPtr<WebGLContextAttributes> getContextAttributes();
193 GLenum getError(); 221 GLenum getError();
194 PassRefPtr<WebGLExtension> getExtension(const String& name); 222 PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(const String& name);
195 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname); 223 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname);
196 WebGLGetInfo getParameter(GLenum pname); 224 WebGLGetInfo getParameter(GLenum pname);
197 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname); 225 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname);
198 String getProgramInfoLog(WebGLProgram*); 226 String getProgramInfoLog(WebGLProgram*);
199 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname); 227 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname);
200 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname); 228 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname);
201 String getShaderInfoLog(WebGLShader*); 229 String getShaderInfoLog(WebGLShader*);
202 PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shade rType, GLenum precisionType); 230 PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat( GLenum shaderType, GLenum precisionType);
203 String getShaderSource(WebGLShader*); 231 String getShaderSource(WebGLShader*);
204 Nullable<Vector<String> > getSupportedExtensions(); 232 Nullable<Vector<String> > getSupportedExtensions();
205 WebGLGetInfo getTexParameter(GLenum target, GLenum pname); 233 WebGLGetInfo getTexParameter(GLenum target, GLenum pname);
206 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*); 234 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*);
207 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const Str ing&); 235 PassRefPtrWillBeRawPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram *, const String&);
208 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname); 236 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname);
209 long long getVertexAttribOffset(GLuint index, GLenum pname); 237 long long getVertexAttribOffset(GLuint index, GLenum pname);
210 238
211 void hint(GLenum target, GLenum mode); 239 void hint(GLenum target, GLenum mode);
212 GLboolean isBuffer(WebGLBuffer*); 240 GLboolean isBuffer(WebGLBuffer*);
213 bool isContextLost() const; 241 bool isContextLost() const;
214 GLboolean isEnabled(GLenum cap); 242 GLboolean isEnabled(GLenum cap);
215 GLboolean isFramebuffer(WebGLFramebuffer*); 243 GLboolean isFramebuffer(WebGLFramebuffer*);
216 GLboolean isProgram(WebGLProgram*); 244 GLboolean isProgram(WebGLProgram*);
217 GLboolean isRenderbuffer(WebGLRenderbuffer*); 245 GLboolean isRenderbuffer(WebGLRenderbuffer*);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void removeSharedObject(WebGLSharedObject*); 371 void removeSharedObject(WebGLSharedObject*);
344 void removeContextObject(WebGLContextObject*); 372 void removeContextObject(WebGLContextObject*);
345 373
346 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } 374 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; }
347 375
348 // ActiveDOMObject notifications 376 // ActiveDOMObject notifications
349 virtual bool hasPendingActivity() const OVERRIDE; 377 virtual bool hasPendingActivity() const OVERRIDE;
350 virtual void stop() OVERRIDE; 378 virtual void stop() OVERRIDE;
351 379
352 void setSavingImage(bool isSaving) { m_savingImage = isSaving; } 380 void setSavingImage(bool isSaving) { m_savingImage = isSaving; }
381
382 virtual void trace(Visitor*) OVERRIDE;
383
384 class TextureUnitState {
385 ALLOW_ONLY_INLINE_ALLOCATION();
386 public:
387 RefPtrWillBeMember<WebGLTexture> m_texture2DBinding;
388 RefPtrWillBeMember<WebGLTexture> m_textureCubeMapBinding;
389
390 void trace(Visitor*);
391 };
392
353 protected: 393 protected:
354 friend class WebGLDrawBuffers; 394 friend class WebGLDrawBuffers;
355 friend class WebGLFramebuffer; 395 friend class WebGLFramebuffer;
356 friend class WebGLObject; 396 friend class WebGLObject;
397 friend class WebGLContextObject;
357 friend class OESVertexArrayObject; 398 friend class OESVertexArrayObject;
358 friend class WebGLDebugShaders; 399 friend class WebGLDebugShaders;
359 friend class WebGLCompressedTextureATC; 400 friend class WebGLCompressedTextureATC;
360 friend class WebGLCompressedTextureETC1; 401 friend class WebGLCompressedTextureETC1;
361 friend class WebGLCompressedTexturePVRTC; 402 friend class WebGLCompressedTexturePVRTC;
362 friend class WebGLCompressedTextureS3TC; 403 friend class WebGLCompressedTextureS3TC;
363 friend class WebGLRenderingContextErrorMessageCallback; 404 friend class WebGLRenderingContextErrorMessageCallback;
364 friend class WebGLVertexArrayObjectOES; 405 friend class WebGLVertexArrayObjectOES;
365 friend class ScopedTexture2DRestorer; 406 friend class ScopedTexture2DRestorer;
366 407
367 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*); 408 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*);
368 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsC ontext3D>); 409 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsC ontext3D>);
369 void initializeNewContext(); 410 void initializeNewContext();
370 void setupFlags(); 411 void setupFlags();
371 412
413 #if ENABLE(OILPAN)
414 PassRefPtr<WebGLSharedWebGraphicsContext3D> sharedWebGraphicsContext3D() { r eturn m_sharedWebGraphicsContext3D; }
415 #endif
416
372 void addSharedObject(WebGLSharedObject*); 417 void addSharedObject(WebGLSharedObject*);
373 void addContextObject(WebGLContextObject*); 418 void addContextObject(WebGLContextObject*);
374 void detachAndRemoveAllObjects(); 419 void detachAndRemoveAllObjects();
375 420
376 void destroyContext(); 421 void destroyContext();
377 void markContextChanged(ContentChangeType); 422 void markContextChanged(ContentChangeType);
378 423
379 // Query if the GL implementation is NPOT strict. 424 // Query if the GL implementation is NPOT strict.
380 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } 425 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; }
381 // Query if depth_stencil buffer is supported. 426 // Query if depth_stencil buffer is supported.
(...skipping 14 matching lines...) Expand all
396 441
397 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const c har* functionName); 442 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const c har* functionName);
398 443
399 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); 444 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy);
400 445
401 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*); 446 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*);
402 447
403 // Structure for rendering to a DrawingBuffer, instead of directly 448 // Structure for rendering to a DrawingBuffer, instead of directly
404 // to the back-buffer of m_context. 449 // to the back-buffer of m_context.
405 RefPtr<DrawingBuffer> m_drawingBuffer; 450 RefPtr<DrawingBuffer> m_drawingBuffer;
451 #if ENABLE(OILPAN)
452 RefPtr<WebGLSharedWebGraphicsContext3D> m_sharedWebGraphicsContext3D;
453 #endif
454
406 RefPtr<WebGLContextGroup> m_contextGroup; 455 RefPtr<WebGLContextGroup> m_contextGroup;
407 456
408 // Dispatches a context lost event once it is determined that one is needed. 457 // 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 458 // 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 459 // 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 460 // on how exactly the platform discovers that the context was lost. For bett er
412 // portability we always defer the dispatch of the event. 461 // portability we always defer the dispatch of the event.
413 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; 462 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
414 bool m_restoreAllowed; 463 bool m_restoreAllowed;
415 Timer<WebGLRenderingContextBase> m_restoreTimer; 464 Timer<WebGLRenderingContextBase> m_restoreTimer;
416 465
417 bool m_needsUpdate; 466 bool m_needsUpdate;
418 bool m_markedCanvasDirty; 467 bool m_markedCanvasDirty;
419 HashSet<WebGLContextObject*> m_contextObjects; 468 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObje cts;
420 469
421 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; 470 OwnPtrWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallbackA dapter;
422 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter; 471 OwnPtrWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMessage CallbackAdapter;
423 472
424 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER 473 // 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; 474 RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer;
426 475
427 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; 476 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
428 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; 477 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
429 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayOb ject) 478 void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObject OES> arrayObject)
430 { 479 {
431 if (arrayObject) 480 if (arrayObject)
432 m_boundVertexArrayObject = arrayObject; 481 m_boundVertexArrayObject = arrayObject;
433 else 482 else
434 m_boundVertexArrayObject = m_defaultVertexArrayObject; 483 m_boundVertexArrayObject = m_defaultVertexArrayObject;
435 } 484 }
436 485
437 class VertexAttribValue { 486 class VertexAttribValue {
438 public: 487 public:
439 VertexAttribValue() 488 VertexAttribValue()
440 { 489 {
441 initValue(); 490 initValue();
442 } 491 }
443 492
444 void initValue() 493 void initValue()
445 { 494 {
446 value[0] = 0.0f; 495 value[0] = 0.0f;
447 value[1] = 0.0f; 496 value[1] = 0.0f;
448 value[2] = 0.0f; 497 value[2] = 0.0f;
449 value[3] = 1.0f; 498 value[3] = 1.0f;
450 } 499 }
451 500
452 GLfloat value[4]; 501 GLfloat value[4];
453 }; 502 };
454 Vector<VertexAttribValue> m_vertexAttribValue; 503 Vector<VertexAttribValue> m_vertexAttribValue;
455 unsigned m_maxVertexAttribs; 504 unsigned m_maxVertexAttribs;
456 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; 505 RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer;
457 long m_vertexAttrib0BufferSize; 506 long m_vertexAttrib0BufferSize;
458 GLfloat m_vertexAttrib0BufferValue[4]; 507 GLfloat m_vertexAttrib0BufferValue[4];
459 bool m_forceAttrib0BufferRefill; 508 bool m_forceAttrib0BufferRefill;
460 bool m_vertexAttrib0UsedBefore; 509 bool m_vertexAttrib0UsedBefore;
461 510
462 RefPtr<WebGLProgram> m_currentProgram; 511 RefPtrWillBeMember<WebGLProgram> m_currentProgram;
463 RefPtr<WebGLFramebuffer> m_framebufferBinding; 512 RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding;
464 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; 513 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding;
465 class TextureUnitState { 514
466 public: 515 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; 516 unsigned long m_activeTextureUnit;
472 517
473 RefPtr<WebGLTexture> m_blackTexture2D; 518 RefPtrWillBeMember<WebGLTexture> m_blackTexture2D;
474 RefPtr<WebGLTexture> m_blackTextureCubeMap; 519 RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap;
475 520
476 Vector<GLenum> m_compressedTextureFormats; 521 Vector<GLenum> m_compressedTextureFormats;
477 522
478 // Fixed-size cache of reusable image buffers for video texImage2D calls. 523 // Fixed-size cache of reusable image buffers for video texImage2D calls.
479 class LRUImageBufferCache { 524 class LRUImageBufferCache {
480 public: 525 public:
481 LRUImageBufferCache(int capacity); 526 LRUImageBufferCache(int capacity);
482 // The pointer returned is owned by the image buffer map. 527 // The pointer returned is owned by the image buffer map.
483 ImageBuffer* imageBuffer(const IntSize& size); 528 ImageBuffer* imageBuffer(const IntSize& size);
484 private: 529 private:
(...skipping 16 matching lines...) Expand all
501 bool m_drawBuffersWebGLRequirementsChecked; 546 bool m_drawBuffersWebGLRequirementsChecked;
502 bool m_drawBuffersSupported; 547 bool m_drawBuffersSupported;
503 548
504 GLint m_packAlignment; 549 GLint m_packAlignment;
505 GLint m_unpackAlignment; 550 GLint m_unpackAlignment;
506 bool m_unpackFlipY; 551 bool m_unpackFlipY;
507 bool m_unpackPremultiplyAlpha; 552 bool m_unpackPremultiplyAlpha;
508 GLenum m_unpackColorspaceConversion; 553 GLenum m_unpackColorspaceConversion;
509 bool m_contextLost; 554 bool m_contextLost;
510 LostContextMode m_contextLostMode; 555 LostContextMode m_contextLostMode;
511 RefPtr<WebGLContextAttributes> m_requestedAttributes; 556 RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes;
512 557
513 bool m_layerCleared; 558 bool m_layerCleared;
514 GLfloat m_clearColor[4]; 559 GLfloat m_clearColor[4];
515 bool m_scissorEnabled; 560 bool m_scissorEnabled;
516 GLfloat m_clearDepth; 561 GLfloat m_clearDepth;
517 GLint m_clearStencil; 562 GLint m_clearStencil;
518 GLboolean m_colorMask[4]; 563 GLboolean m_colorMask[4];
519 GLboolean m_depthMask; 564 GLboolean m_depthMask;
520 565
521 bool m_stencilEnabled; 566 bool m_stencilEnabled;
(...skipping 16 matching lines...) Expand all
538 OwnPtr<Extensions3DUtil> m_extensionsUtil; 583 OwnPtr<Extensions3DUtil> m_extensionsUtil;
539 584
540 bool m_savingImage; 585 bool m_savingImage;
541 586
542 enum ExtensionFlags { 587 enum ExtensionFlags {
543 ApprovedExtension = 0x00, 588 ApprovedExtension = 0x00,
544 // Extension that is behind the draft extensions runtime flag: 589 // Extension that is behind the draft extensions runtime flag:
545 DraftExtension = 0x01, 590 DraftExtension = 0x01,
546 }; 591 };
547 592
548 class ExtensionTracker { 593 class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracke r> {
549 public: 594 public:
550 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) 595 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes)
551 : m_draft(flags & DraftExtension) 596 : m_draft(flags & DraftExtension)
552 , m_prefixes(prefixes) 597 , m_prefixes(prefixes)
553 { 598 {
554 } 599 }
555 600
601 #if !ENABLE(OILPAN)
556 virtual ~ExtensionTracker() 602 virtual ~ExtensionTracker()
557 { 603 {
558 } 604 }
605 #endif
559 606
560 bool draft() const 607 bool draft() const
561 { 608 {
562 return m_draft; 609 return m_draft;
563 } 610 }
564 611
565 const char* const* prefixes() const; 612 const char* const* prefixes() const;
566 bool matchesNameWithPrefixes(const String&) const; 613 bool matchesNameWithPrefixes(const String&) const;
567 614
568 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e*) = 0; 615 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase*) = 0;
569 virtual bool supported(WebGLRenderingContextBase*) const = 0; 616 virtual bool supported(WebGLRenderingContextBase*) const = 0;
570 virtual const char* extensionName() const = 0; 617 virtual const char* extensionName() const = 0;
571 virtual void loseExtension() = 0; 618 virtual void loseExtension() = 0;
572 619
620 virtual void trace(Visitor*) { }
621
573 private: 622 private:
574 bool m_draft; 623 bool m_draft;
575 const char* const* m_prefixes; 624 const char* const* m_prefixes;
576 }; 625 };
577 626
578 template <typename T> 627 template <typename T>
579 class TypedExtensionTracker FINAL : public ExtensionTracker { 628 class TypedExtensionTracker FINAL : public ExtensionTracker {
580 public: 629 public:
581 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes) 630 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 { 631 {
632 return adoptPtrWillBeNoop(new TypedExtensionTracker<T>(extensionFiel d, flags, prefixes));
586 } 633 }
587 634
635 #if !ENABLE(OILPAN)
588 virtual ~TypedExtensionTracker() 636 virtual ~TypedExtensionTracker()
589 { 637 {
590 if (m_extension) { 638 if (m_extension) {
591 m_extension->lose(true); 639 m_extension->lose(true);
592 m_extension = nullptr; 640 m_extension = nullptr;
593 } 641 }
594 } 642 }
643 #endif
595 644
596 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e* context) OVERRIDE 645 virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderi ngContextBase* context) OVERRIDE
597 { 646 {
598 if (!m_extension) { 647 if (!m_extension) {
599 m_extension = T::create(context); 648 m_extension = T::create(context);
600 m_extensionField = m_extension; 649 m_extensionField = m_extension;
601 } 650 }
602 651
603 return m_extension; 652 return m_extension;
604 } 653 }
605 654
606 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E 655 virtual bool supported(WebGLRenderingContextBase* context) const OVERRID E
607 { 656 {
608 return T::supported(context); 657 return T::supported(context);
609 } 658 }
610 659
611 virtual const char* extensionName() const OVERRIDE 660 virtual const char* extensionName() const OVERRIDE
612 { 661 {
613 return T::extensionName(); 662 return T::extensionName();
614 } 663 }
615 664
616 virtual void loseExtension() OVERRIDE 665 virtual void loseExtension() OVERRIDE
617 { 666 {
618 if (m_extension) { 667 if (m_extension) {
619 m_extension->lose(false); 668 m_extension->lose(false);
620 if (m_extension->isLost()) 669 if (m_extension->isLost())
621 m_extension = nullptr; 670 m_extension = nullptr;
622 } 671 }
623 } 672 }
624 673
674 virtual void trace(Visitor* visitor) OVERRIDE
675 {
676 visitor->trace(m_extension);
677 visitor->trace(m_extensionField);
678 ExtensionTracker::trace(visitor);
679 }
680
625 private: 681 private:
626 RefPtr<T>& m_extensionField; 682 TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFl ags flags, const char* const* prefixes)
683 : ExtensionTracker(flags, prefixes)
684 , m_extensionField(extensionField)
685 {
686 }
687
688 RefPtrWillBeMember<T>& m_extensionField;
627 // ExtensionTracker holds it's own reference to the extension to ensure 689 // ExtensionTracker holds it's own reference to the extension to ensure
628 // that it is not deleted before this object's destructor is called 690 // that it is not deleted before this object's destructor is called
629 RefPtr<T> m_extension; 691 RefPtrWillBeMember<T> m_extension;
630 }; 692 };
631 693
632 bool m_extensionEnabled[WebGLExtensionNameCount]; 694 bool m_extensionEnabled[WebGLExtensionNameCount];
633 Vector<ExtensionTracker*> m_extensions; 695 WillBeHeapVector<OwnPtrWillBeMember<ExtensionTracker> > m_extensions;
634 696
635 template <typename T> 697 template <typename T>
636 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char* const* prefixes = 0) 698 void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags f lags = ApprovedExtension, const char* const* prefixes = 0)
637 { 699 {
638 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes)); 700 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags , prefixes));
639 } 701 }
640 702
641 bool extensionSupportedAndAllowed(const ExtensionTracker*); 703 bool extensionSupportedAndAllowed(const ExtensionTracker*);
642 704
643 inline bool extensionEnabled(WebGLExtensionName name) 705 inline bool extensionEnabled(WebGLExtensionName name)
644 { 706 {
645 return m_extensionEnabled[name]; 707 return m_extensionEnabled[name];
646 } 708 }
647 709
648 // Errors raised by synthesizeGLError() while the context is lost. 710 // Errors raised by synthesizeGLError() while the context is lost.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 // Return the least recently used context's position in the active context v ector. 964 // 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. 965 // If the vector is empty, return the maximum allowed active context number.
904 static size_t oldestContextIndex(); 966 static size_t oldestContextIndex();
905 static IntSize oldestContextSize(); 967 static IntSize oldestContextSize();
906 }; 968 };
907 969
908 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 970 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
909 971
910 } // namespace WebCore 972 } // namespace WebCore
911 973
974 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(WebCore::WebGLRenderingContex tBase::TextureUnitState);
975
912 #endif // WebGLRenderingContextBase_h 976 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698