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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h

Issue 2547813002: Remove WebGLObject maps from WebGLRenderingContextBase and WebGLContextGroup. (Closed)
Patch Set: Fixed WebGLContextObject::validate. Made WebGLExtension non-finalized. Created 4 years 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 class WebGLDebugShaders; 94 class WebGLDebugShaders;
95 class WebGLDepthTexture; 95 class WebGLDepthTexture;
96 class WebGLDrawBuffers; 96 class WebGLDrawBuffers;
97 class WebGLExtension; 97 class WebGLExtension;
98 class WebGLFramebuffer; 98 class WebGLFramebuffer;
99 class WebGLObject; 99 class WebGLObject;
100 class WebGLProgram; 100 class WebGLProgram;
101 class WebGLRenderbuffer; 101 class WebGLRenderbuffer;
102 class WebGLShader; 102 class WebGLShader;
103 class WebGLShaderPrecisionFormat; 103 class WebGLShaderPrecisionFormat;
104 class WebGLSharedObject;
105 class WebGLUniformLocation; 104 class WebGLUniformLocation;
106 class WebGLVertexArrayObjectBase; 105 class WebGLVertexArrayObjectBase;
107 106
108 class WebGLRenderingContextErrorMessageCallback; 107 class WebGLRenderingContextErrorMessageCallback;
109 108
110 // This class uses the color mask to prevent drawing to the alpha channel, if 109 // This class uses the color mask to prevent drawing to the alpha channel, if
111 // the DrawingBuffer requires RGB emulation. 110 // the DrawingBuffer requires RGB emulation.
112 class ScopedRGBEmulationColorMask { 111 class ScopedRGBEmulationColorMask {
113 public: 112 public:
114 ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interface*, 113 ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interface*,
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 WhenAvailable, 521 WhenAvailable,
523 522
524 // Restore as soon as possible, but only when 523 // Restore as soon as possible, but only when
525 // the canvas is visible. 524 // the canvas is visible.
526 Auto 525 Auto
527 }; 526 };
528 void loseContext(LostContextMode) override; 527 void loseContext(LostContextMode) override;
529 void forceLostContext(LostContextMode, AutoRecoveryMethod); 528 void forceLostContext(LostContextMode, AutoRecoveryMethod);
530 void forceRestoreContext(); 529 void forceRestoreContext();
531 void loseContextImpl(LostContextMode, AutoRecoveryMethod); 530 void loseContextImpl(LostContextMode, AutoRecoveryMethod);
531 uint32_t numberOfContextLosses() const;
532 532
533 // Utilities to restore GL state to match the rendering context's 533 // Utilities to restore GL state to match the rendering context's
534 // saved state. Use these after contextGL()-based state changes that 534 // saved state. Use these after contextGL()-based state changes that
535 // bypass the rendering context. 535 // bypass the rendering context.
536 void restoreScissorEnabled(); 536 void restoreScissorEnabled();
537 void restoreScissorBox(); 537 void restoreScissorBox();
538 void restoreClearColor(); 538 void restoreClearColor();
539 void restoreColorMask(); 539 void restoreColorMask();
540 540
541 gpu::gles2::GLES2Interface* contextGL() const { 541 gpu::gles2::GLES2Interface* contextGL() const {
542 DrawingBuffer* d = drawingBuffer(); 542 DrawingBuffer* d = drawingBuffer();
543 if (!d) 543 if (!d)
544 return nullptr; 544 return nullptr;
545 return d->contextGL(); 545 return d->contextGL();
546 } 546 }
547 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } 547 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); }
548 Extensions3DUtil* extensionsUtil(); 548 Extensions3DUtil* extensionsUtil();
549 549
550 void reshape(int width, int height) override; 550 void reshape(int width, int height) override;
551 551
552 void markLayerComposited() override; 552 void markLayerComposited() override;
553 ImageData* paintRenderingResultsToImageData(SourceDrawingBuffer) override; 553 ImageData* paintRenderingResultsToImageData(SourceDrawingBuffer) override;
554 554
555 void removeSharedObject(WebGLSharedObject*);
556 void removeContextObject(WebGLContextObject*);
557
558 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } 555 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; }
559 556
560 // Eagerly finalize WebGLRenderingContextBase in order for it
561 // to (first) be able to detach its WebGLContextObjects, before
562 // they're later swept and finalized.
563 EAGERLY_FINALIZE();
564 DECLARE_EAGER_FINALIZATION_OPERATOR_NEW();
565 DECLARE_VIRTUAL_TRACE(); 557 DECLARE_VIRTUAL_TRACE();
566 558
567 DECLARE_VIRTUAL_TRACE_WRAPPERS(); 559 DECLARE_VIRTUAL_TRACE_WRAPPERS();
568 560
569 // Returns approximate gpu memory allocated per pixel. 561 // Returns approximate gpu memory allocated per pixel.
570 int externallyAllocatedBytesPerPixel() override; 562 int externallyAllocatedBytesPerPixel() override;
571 563
572 class TextureUnitState { 564 class TextureUnitState {
573 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 565 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
574 566
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // DrawingBuffer::Client implementation. 632 // DrawingBuffer::Client implementation.
641 bool DrawingBufferClientIsBoundForDraw() override; 633 bool DrawingBufferClientIsBoundForDraw() override;
642 void DrawingBufferClientRestoreScissorTest() override; 634 void DrawingBufferClientRestoreScissorTest() override;
643 void DrawingBufferClientRestoreMaskAndClearValues() override; 635 void DrawingBufferClientRestoreMaskAndClearValues() override;
644 void DrawingBufferClientRestorePixelPackAlignment() override; 636 void DrawingBufferClientRestorePixelPackAlignment() override;
645 void DrawingBufferClientRestoreTexture2DBinding() override; 637 void DrawingBufferClientRestoreTexture2DBinding() override;
646 void DrawingBufferClientRestoreRenderbufferBinding() override; 638 void DrawingBufferClientRestoreRenderbufferBinding() override;
647 void DrawingBufferClientRestoreFramebufferBinding() override; 639 void DrawingBufferClientRestoreFramebufferBinding() override;
648 void DrawingBufferClientRestorePixelUnpackBufferBinding() override; 640 void DrawingBufferClientRestorePixelUnpackBufferBinding() override;
649 641
650 void addSharedObject(WebGLSharedObject*);
651 void addContextObject(WebGLContextObject*);
652 void detachAndRemoveAllObjects();
653
654 virtual void destroyContext(); 642 virtual void destroyContext();
655 void markContextChanged(ContentChangeType); 643 void markContextChanged(ContentChangeType);
656 644
657 void onErrorMessage(const char*, int32_t id); 645 void onErrorMessage(const char*, int32_t id);
658 646
659 void notifyCanvasContextChanged(); 647 void notifyCanvasContextChanged();
660 648
661 // Query if depth_stencil buffer is supported. 649 // Query if depth_stencil buffer is supported.
662 bool isDepthStencilSupported() { return m_isDepthStencilSupported; } 650 bool isDepthStencilSupported() { return m_isDepthStencilSupported; }
663 651
(...skipping 23 matching lines...) Expand all
687 int height, 675 int height,
688 const char* functionName); 676 const char* functionName);
689 677
690 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*); 678 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*);
691 679
692 // Structure for rendering to a DrawingBuffer, instead of directly 680 // Structure for rendering to a DrawingBuffer, instead of directly
693 // to the back-buffer of m_context. 681 // to the back-buffer of m_context.
694 RefPtr<DrawingBuffer> m_drawingBuffer; 682 RefPtr<DrawingBuffer> m_drawingBuffer;
695 DrawingBuffer* drawingBuffer() const; 683 DrawingBuffer* drawingBuffer() const;
696 684
697 RefPtr<WebGLContextGroup> m_contextGroup; 685 TraceWrapperMember<WebGLContextGroup> m_contextGroup;
698 686
699 bool m_isHidden; 687 bool m_isHidden;
700 LostContextMode m_contextLostMode; 688 LostContextMode m_contextLostMode;
701 AutoRecoveryMethod m_autoRecoveryMethod; 689 AutoRecoveryMethod m_autoRecoveryMethod;
702 // Dispatches a context lost event once it is determined that one is needed. 690 // Dispatches a context lost event once it is determined that one is needed.
703 // This is used for synthetic, WEBGL_lose_context and real context losses. For 691 // This is used for synthetic, WEBGL_lose_context and real context losses. For
704 // real ones, it's likely that there's no JavaScript on the stack, but that 692 // real ones, it's likely that there's no JavaScript on the stack, but that
705 // might be dependent on how exactly the platform discovers that the context 693 // might be dependent on how exactly the platform discovers that the context
706 // was lost. For better portability we always defer the dispatch of the event. 694 // was lost. For better portability we always defer the dispatch of the event.
707 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; 695 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
708 bool m_restoreAllowed; 696 bool m_restoreAllowed;
709 Timer<WebGLRenderingContextBase> m_restoreTimer; 697 Timer<WebGLRenderingContextBase> m_restoreTimer;
710 698
711 bool m_markedCanvasDirty; 699 bool m_markedCanvasDirty;
712 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects;
713 700
714 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and 701 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and
715 // stored values for ELEMENT_ARRAY_BUFFER 702 // stored values for ELEMENT_ARRAY_BUFFER
716 TraceWrapperMember<WebGLBuffer> m_boundArrayBuffer; 703 TraceWrapperMember<WebGLBuffer> m_boundArrayBuffer;
717 704
718 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; 705 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
719 TraceWrapperMember<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; 706 TraceWrapperMember<WebGLVertexArrayObjectBase> m_boundVertexArrayObject;
720 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*); 707 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*);
721 708
722 enum VertexAttribValueType { 709 enum VertexAttribValueType {
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 GLsizei height, 1505 GLsizei height,
1519 const char* functionName); 1506 const char* functionName);
1520 1507
1521 friend class WebGLStateRestorer; 1508 friend class WebGLStateRestorer;
1522 friend class WebGLRenderingContextEvictionManager; 1509 friend class WebGLRenderingContextEvictionManager;
1523 1510
1524 static void activateContext(WebGLRenderingContextBase*); 1511 static void activateContext(WebGLRenderingContextBase*);
1525 static void deactivateContext(WebGLRenderingContextBase*); 1512 static void deactivateContext(WebGLRenderingContextBase*);
1526 static void addToEvictedList(WebGLRenderingContextBase*); 1513 static void addToEvictedList(WebGLRenderingContextBase*);
1527 static void removeFromEvictedList(WebGLRenderingContextBase*); 1514 static void removeFromEvictedList(WebGLRenderingContextBase*);
1528 static void willDestroyContext(WebGLRenderingContextBase*); 1515 static void restoreEvictedContext(WebGLRenderingContextBase*);
1529 static void forciblyLoseOldestContext(const String& reason); 1516 static void forciblyLoseOldestContext(const String& reason);
1530 // Return the least recently used context's position in the active context 1517 // Return the least recently used context's position in the active context
1531 // vector. If the vector is empty, return the maximum allowed active context 1518 // vector. If the vector is empty, return the maximum allowed active context
1532 // number. 1519 // number.
1533 static WebGLRenderingContextBase* oldestContext(); 1520 static WebGLRenderingContextBase* oldestContext();
1534 static WebGLRenderingContextBase* oldestEvictedContext(); 1521 static WebGLRenderingContextBase* oldestEvictedContext();
1535 1522
1536 ImageBitmap* transferToImageBitmapBase(ScriptState*); 1523 ImageBitmap* transferToImageBitmapBase(ScriptState*);
1537 1524
1538 // Helper functions for tex(Sub)Image2D && texSubImage3D 1525 // Helper functions for tex(Sub)Image2D && texSubImage3D
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 context, 1655 context,
1669 context->is3d(), 1656 context->is3d(),
1670 context.is3d()); 1657 context.is3d());
1671 1658
1672 } // namespace blink 1659 } // namespace blink
1673 1660
1674 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( 1661 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(
1675 blink::WebGLRenderingContextBase::TextureUnitState); 1662 blink::WebGLRenderingContextBase::TextureUnitState);
1676 1663
1677 #endif // WebGLRenderingContextBase_h 1664 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698