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

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

Issue 15876011: Make WebGL extensions get lost when context is lost. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // like GL_FLOAT, GL_INT, etc. 357 // like GL_FLOAT, GL_INT, etc.
358 unsigned int sizeInBytes(GC3Denum type); 358 unsigned int sizeInBytes(GC3Denum type);
359 359
360 // Check if each enabled vertex attribute is bound to a buffer. 360 // Check if each enabled vertex attribute is bound to a buffer.
361 bool validateRenderingState(); 361 bool validateRenderingState();
362 362
363 bool validateWebGLObject(const char*, WebGLObject*); 363 bool validateWebGLObject(const char*, WebGLObject*);
364 364
365 // Adds a compressed texture format. 365 // Adds a compressed texture format.
366 void addCompressedTextureFormat(GC3Denum); 366 void addCompressedTextureFormat(GC3Denum);
367 void removeAllCompressedTextureFormats();
367 368
368 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy, Exc eptionCode&); 369 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy, Exc eptionCode&);
369 370
370 RefPtr<GraphicsContext3D> m_context; 371 RefPtr<GraphicsContext3D> m_context;
371 RefPtr<WebGLContextGroup> m_contextGroup; 372 RefPtr<WebGLContextGroup> m_contextGroup;
372 373
373 // Structure for rendering to a DrawingBuffer, instead of directly 374 // Structure for rendering to a DrawingBuffer, instead of directly
374 // to the back-buffer of m_context. 375 // to the back-buffer of m_context.
375 RefPtr<DrawingBuffer> m_drawingBuffer; 376 RefPtr<DrawingBuffer> m_drawingBuffer;
376 377
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 GC3Duint m_stencilFuncMask, m_stencilFuncMaskBack; 492 GC3Duint m_stencilFuncMask, m_stencilFuncMaskBack;
492 493
493 bool m_isGLES2NPOTStrict; 494 bool m_isGLES2NPOTStrict;
494 bool m_isDepthStencilSupported; 495 bool m_isDepthStencilSupported;
495 bool m_isRobustnessEXTSupported; 496 bool m_isRobustnessEXTSupported;
496 497
497 bool m_synthesizedErrorsToConsole; 498 bool m_synthesizedErrorsToConsole;
498 int m_numGLErrorsToConsoleAllowed; 499 int m_numGLErrorsToConsoleAllowed;
499 500
500 // Enabled extension objects. 501 // Enabled extension objects.
501 OwnPtr<EXTDrawBuffers> m_extDrawBuffers; 502 EXTDrawBuffers* m_extDrawBuffers;
502 OwnPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic; 503 EXTTextureFilterAnisotropic* m_extTextureFilterAnisotropic;
503 OwnPtr<OESTextureFloat> m_oesTextureFloat; 504 OESTextureFloat* m_oesTextureFloat;
504 OwnPtr<OESTextureFloatLinear> m_oesTextureFloatLinear; 505 OESTextureFloatLinear* m_oesTextureFloatLinear;
505 OwnPtr<OESTextureHalfFloat> m_oesTextureHalfFloat; 506 OESTextureHalfFloat* m_oesTextureHalfFloat;
506 OwnPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear; 507 OESTextureHalfFloatLinear* m_oesTextureHalfFloatLinear;
507 OwnPtr<OESStandardDerivatives> m_oesStandardDerivatives; 508 OESStandardDerivatives* m_oesStandardDerivatives;
508 OwnPtr<OESVertexArrayObject> m_oesVertexArrayObject; 509 OESVertexArrayObject* m_oesVertexArrayObject;
509 OwnPtr<OESElementIndexUint> m_oesElementIndexUint; 510 OESElementIndexUint* m_oesElementIndexUint;
510 OwnPtr<WebGLLoseContext> m_webglLoseContext; 511 WebGLLoseContext* m_webglLoseContext;
511 OwnPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo; 512 WebGLDebugRendererInfo* m_webglDebugRendererInfo;
512 OwnPtr<WebGLDebugShaders> m_webglDebugShaders; 513 WebGLDebugShaders* m_webglDebugShaders;
513 OwnPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC; 514 WebGLCompressedTextureATC* m_webglCompressedTextureATC;
514 OwnPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC; 515 WebGLCompressedTexturePVRTC* m_webglCompressedTexturePVRTC;
515 OwnPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC; 516 WebGLCompressedTextureS3TC* m_webglCompressedTextureS3TC;
516 OwnPtr<WebGLDepthTexture> m_webglDepthTexture; 517 WebGLDepthTexture* m_webglDepthTexture;
517 518
518 class ExtensionTracker { 519 class ExtensionTracker {
519 public: 520 public:
520 ExtensionTracker(bool privileged, bool prefixed, const char** prefixes) 521 ExtensionTracker(bool privileged, bool prefixed, const char** prefixes)
521 : m_privileged(privileged) 522 : m_privileged(privileged)
522 , m_prefixed(prefixed) 523 , m_prefixed(prefixed)
523 , m_prefixes(prefixes) 524 , m_prefixes(prefixes)
524 { 525 {
525 } 526 }
526 527
528 virtual ~ExtensionTracker()
529 {
530 }
531
527 bool getPrefixed() const 532 bool getPrefixed() const
528 { 533 {
529 return m_prefixed; 534 return m_prefixed;
530 } 535 }
531 536
532 bool getPrivileged() const 537 bool getPrivileged() const
533 { 538 {
534 return m_privileged; 539 return m_privileged;
535 } 540 }
536 541
537 bool matchesNameWithPrefixes(const String&) const; 542 bool matchesNameWithPrefixes(const String&) const;
538 543
539 virtual WebGLExtension* getExtension(WebGLRenderingContext*) const = 0; 544 virtual WebGLExtension* getExtension(WebGLRenderingContext*) = 0;
540 virtual bool supported(WebGLRenderingContext*) const = 0; 545 virtual bool supported(WebGLRenderingContext*) const = 0;
541 virtual const char* getExtensionName() const = 0; 546 virtual const char* getExtensionName() const = 0;
547 virtual void loseExtension() = 0;
542 548
543 private: 549 private:
544 bool m_privileged; 550 bool m_privileged;
545 bool m_prefixed; 551 bool m_prefixed;
546 const char** m_prefixes; 552 const char** m_prefixes;
547 }; 553 };
548 554
555 // This class owns the extension and keeps a reference to the
556 // WebGLRenderingContext field the same extension.
549 template <typename T> 557 template <typename T>
550 class TypedExtensionTracker : public ExtensionTracker { 558 class TypedExtensionTracker : public ExtensionTracker {
551 public: 559 public:
552 TypedExtensionTracker(OwnPtr<T>& extensionField, bool privileged, bool p refixed, const char** prefixes) 560 TypedExtensionTracker(T*& extensionField, bool privileged, bool prefixed , const char** prefixes)
553 : ExtensionTracker(privileged, prefixed, prefixes) 561 : ExtensionTracker(privileged, prefixed, prefixes)
554 , m_extensionField(extensionField) 562 , m_extensionField(extensionField)
555 { 563 {
564 m_extensionField = 0;
556 } 565 }
557 566
558 virtual WebGLExtension* getExtension(WebGLRenderingContext* context) con st 567 virtual WebGLExtension* getExtension(WebGLRenderingContext* context)
559 { 568 {
560 if (!m_extensionField) 569 if (!m_extension)
561 m_extensionField = T::create(context); 570 m_extension = T::create(context);
Ken Russell (switch to Gerrit) 2013/06/05 00:46:38 Should this also call m_extension->enable()? That
562 571
563 return m_extensionField.get(); 572 if (m_extension->isLost())
573 m_extension->restore();
574
575 m_extensionField = m_extension.get();
576 return m_extensionField;
564 } 577 }
565 578
566 virtual bool supported(WebGLRenderingContext* context) const 579 virtual bool supported(WebGLRenderingContext* context) const
567 { 580 {
568 return T::supported(context); 581 return T::supported(context);
569 } 582 }
570 583
571 virtual const char* getExtensionName() const 584 virtual const char* getExtensionName() const
572 { 585 {
573 return T::getExtensionName(); 586 return T::getExtensionName();
574 } 587 }
575 588
589 virtual void loseExtension()
590 {
591 m_extensionField = 0; // removes the extension's field from WebGLRen deringContext
592 if (m_extension)
593 m_extension->lose();
594 }
595
576 private: 596 private:
577 OwnPtr<T>& m_extensionField; 597 T*& m_extensionField; // reference to the typed field in WebGLRenderingC ontext
598 OwnPtr<T> m_extension;
578 }; 599 };
579 600
580 Vector<ExtensionTracker*> m_extensions; 601 Vector<ExtensionTracker*> m_extensions;
581 602
582 template <typename T> 603 template <typename T>
583 void registerExtension(OwnPtr<T>& extensionPtr, bool privileged, bool prefix ed, const char** prefixes) 604 void registerExtension(T*& extensionPtr, bool privileged, bool prefixed, con st char** prefixes)
584 { 605 {
585 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, privilege d, prefixed, prefixes)); 606 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, privilege d, prefixed, prefixes));
586 } 607 }
587 608
588 // Errors raised by synthesizeGLError() while the context is lost. 609 // Errors raised by synthesizeGLError() while the context is lost.
589 Vector<GC3Denum> lost_context_errors_; 610 Vector<GC3Denum> lost_context_errors_;
590 611
591 // Helpers for getParameter and others 612 // Helpers for getParameter and others
592 WebGLGetInfo getBooleanParameter(GC3Denum); 613 WebGLGetInfo getBooleanParameter(GC3Denum);
593 WebGLGetInfo getBooleanArrayParameter(GC3Denum); 614 WebGLGetInfo getBooleanArrayParameter(GC3Denum);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 static void activateContext(WebGLRenderingContext*); 857 static void activateContext(WebGLRenderingContext*);
837 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList ); 858 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList );
838 static void willDestroyContext(WebGLRenderingContext*); 859 static void willDestroyContext(WebGLRenderingContext*);
839 static void forciblyLoseOldestContext(const String& reason); 860 static void forciblyLoseOldestContext(const String& reason);
840 static IntSize oldestContextSize(); 861 static IntSize oldestContextSize();
841 }; 862 };
842 863
843 } // namespace WebCore 864 } // namespace WebCore
844 865
845 #endif 866 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698