| OLD | NEW |
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 class WebGLShader; | 85 class WebGLShader; |
| 86 class WebGLShaderPrecisionFormat; | 86 class WebGLShaderPrecisionFormat; |
| 87 class WebGLSharedObject; | 87 class WebGLSharedObject; |
| 88 class WebGLTexture; | 88 class WebGLTexture; |
| 89 class WebGLUniformLocation; | 89 class WebGLUniformLocation; |
| 90 class WebGLVertexArrayObjectOES; | 90 class WebGLVertexArrayObjectOES; |
| 91 | 91 |
| 92 class WebGLRenderingContextLostCallback; | 92 class WebGLRenderingContextLostCallback; |
| 93 class WebGLRenderingContextErrorMessageCallback; | 93 class WebGLRenderingContextErrorMessageCallback; |
| 94 | 94 |
| 95 class WebGLRenderingContext : public CanvasRenderingContext, public ActiveDOMObj
ect, private Page::MultisamplingChangedObserver { | 95 class WebGLRenderingContext FINAL : public CanvasRenderingContext, public Active
DOMObject, private Page::MultisamplingChangedObserver { |
| 96 public: | 96 public: |
| 97 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLCon
textAttributes*); | 97 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLCon
textAttributes*); |
| 98 virtual ~WebGLRenderingContext(); | 98 virtual ~WebGLRenderingContext(); |
| 99 | 99 |
| 100 virtual bool is3d() const { return true; } | 100 virtual bool is3d() const { return true; } |
| 101 virtual bool isAccelerated() const { return true; } | 101 virtual bool isAccelerated() const OVERRIDE { return true; } |
| 102 | 102 |
| 103 int drawingBufferWidth() const; | 103 int drawingBufferWidth() const; |
| 104 int drawingBufferHeight() const; | 104 int drawingBufferHeight() const; |
| 105 | 105 |
| 106 void activeTexture(GLenum texture); | 106 void activeTexture(GLenum texture); |
| 107 void attachShader(WebGLProgram*, WebGLShader*); | 107 void attachShader(WebGLProgram*, WebGLShader*); |
| 108 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); | 108 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); |
| 109 void bindBuffer(GLenum target, WebGLBuffer*); | 109 void bindBuffer(GLenum target, WebGLBuffer*); |
| 110 void bindFramebuffer(GLenum target, WebGLFramebuffer*); | 110 void bindFramebuffer(GLenum target, WebGLFramebuffer*); |
| 111 void bindRenderbuffer(GLenum target, WebGLRenderbuffer*); | 111 void bindRenderbuffer(GLenum target, WebGLRenderbuffer*); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // A synthetic lost context that should attempt to recover automatically | 314 // A synthetic lost context that should attempt to recover automatically |
| 315 AutoRecoverSyntheticLostContext | 315 AutoRecoverSyntheticLostContext |
| 316 }; | 316 }; |
| 317 void forceLostContext(LostContextMode); | 317 void forceLostContext(LostContextMode); |
| 318 void forceRestoreContext(); | 318 void forceRestoreContext(); |
| 319 void loseContextImpl(LostContextMode); | 319 void loseContextImpl(LostContextMode); |
| 320 | 320 |
| 321 blink::WebGraphicsContext3D* webGraphicsContext3D() const { return m_context
.get(); } | 321 blink::WebGraphicsContext3D* webGraphicsContext3D() const { return m_context
.get(); } |
| 322 GraphicsContext3D* graphicsContext3D() const { return m_contextSupport.get()
; } | 322 GraphicsContext3D* graphicsContext3D() const { return m_contextSupport.get()
; } |
| 323 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } | 323 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } |
| 324 virtual blink::WebLayer* platformLayer() const; | 324 virtual blink::WebLayer* platformLayer() const OVERRIDE; |
| 325 | 325 |
| 326 void reshape(int width, int height); | 326 void reshape(int width, int height); |
| 327 | 327 |
| 328 void markLayerComposited(); | 328 void markLayerComposited(); |
| 329 virtual void paintRenderingResultsToCanvas(); | 329 virtual void paintRenderingResultsToCanvas() OVERRIDE; |
| 330 virtual PassRefPtr<ImageData> paintRenderingResultsToImageData(); | 330 PassRefPtr<ImageData> paintRenderingResultsToImageData(); |
| 331 | 331 |
| 332 void removeSharedObject(WebGLSharedObject*); | 332 void removeSharedObject(WebGLSharedObject*); |
| 333 void removeContextObject(WebGLContextObject*); | 333 void removeContextObject(WebGLContextObject*); |
| 334 | 334 |
| 335 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } | 335 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } |
| 336 | 336 |
| 337 // ActiveDOMObject notifications | 337 // ActiveDOMObject notifications |
| 338 virtual bool hasPendingActivity() const; | 338 virtual bool hasPendingActivity() const OVERRIDE; |
| 339 virtual void stop(); | 339 virtual void stop() OVERRIDE; |
| 340 | 340 |
| 341 private: | 341 private: |
| 342 friend class WebGLDrawBuffers; | 342 friend class WebGLDrawBuffers; |
| 343 friend class WebGLFramebuffer; | 343 friend class WebGLFramebuffer; |
| 344 friend class WebGLObject; | 344 friend class WebGLObject; |
| 345 friend class OESVertexArrayObject; | 345 friend class OESVertexArrayObject; |
| 346 friend class WebGLDebugShaders; | 346 friend class WebGLDebugShaders; |
| 347 friend class WebGLCompressedTextureATC; | 347 friend class WebGLCompressedTextureATC; |
| 348 friend class WebGLCompressedTexturePVRTC; | 348 friend class WebGLCompressedTexturePVRTC; |
| 349 friend class WebGLCompressedTextureS3TC; | 349 friend class WebGLCompressedTextureS3TC; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 | 600 |
| 601 private: | 601 private: |
| 602 bool m_privileged; | 602 bool m_privileged; |
| 603 bool m_draft; | 603 bool m_draft; |
| 604 bool m_prefixed; | 604 bool m_prefixed; |
| 605 bool m_webglDebugRendererInfo; | 605 bool m_webglDebugRendererInfo; |
| 606 const char* const* m_prefixes; | 606 const char* const* m_prefixes; |
| 607 }; | 607 }; |
| 608 | 608 |
| 609 template <typename T> | 609 template <typename T> |
| 610 class TypedExtensionTracker : public ExtensionTracker { | 610 class TypedExtensionTracker FINAL : public ExtensionTracker { |
| 611 public: | 611 public: |
| 612 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c
onst char* const* prefixes) | 612 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c
onst char* const* prefixes) |
| 613 : ExtensionTracker(flags, prefixes) | 613 : ExtensionTracker(flags, prefixes) |
| 614 , m_extensionField(extensionField) | 614 , m_extensionField(extensionField) |
| 615 { | 615 { |
| 616 } | 616 } |
| 617 | 617 |
| 618 ~TypedExtensionTracker() | 618 ~TypedExtensionTracker() |
| 619 { | 619 { |
| 620 if (m_extensionField) { | 620 if (m_extensionField) { |
| 621 m_extensionField->lose(true); | 621 m_extensionField->lose(true); |
| 622 m_extensionField = 0; | 622 m_extensionField = 0; |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 | 625 |
| 626 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* c
ontext) const | 626 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* c
ontext) const OVERRIDE |
| 627 { | 627 { |
| 628 if (!m_extensionField) | 628 if (!m_extensionField) |
| 629 m_extensionField = T::create(context); | 629 m_extensionField = T::create(context); |
| 630 | 630 |
| 631 return m_extensionField; | 631 return m_extensionField; |
| 632 } | 632 } |
| 633 | 633 |
| 634 virtual bool supported(WebGLRenderingContext* context) const | 634 virtual bool supported(WebGLRenderingContext* context) const OVERRIDE |
| 635 { | 635 { |
| 636 return T::supported(context); | 636 return T::supported(context); |
| 637 } | 637 } |
| 638 | 638 |
| 639 virtual const char* extensionName() const | 639 virtual const char* extensionName() const OVERRIDE |
| 640 { | 640 { |
| 641 return T::extensionName(); | 641 return T::extensionName(); |
| 642 } | 642 } |
| 643 | 643 |
| 644 virtual void loseExtension() | 644 virtual void loseExtension() OVERRIDE |
| 645 { | 645 { |
| 646 if (m_extensionField) { | 646 if (m_extensionField) { |
| 647 m_extensionField->lose(false); | 647 m_extensionField->lose(false); |
| 648 if (m_extensionField->isLost()) | 648 if (m_extensionField->isLost()) |
| 649 m_extensionField = 0; | 649 m_extensionField = 0; |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 private: | 653 private: |
| 654 RefPtr<T>& m_extensionField; | 654 RefPtr<T>& m_extensionField; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 // First time called, if EXT_draw_buffers is supported, query the value; oth
erwise return 0. | 898 // First time called, if EXT_draw_buffers is supported, query the value; oth
erwise return 0. |
| 899 // Later, return the cached value. | 899 // Later, return the cached value. |
| 900 GLint maxDrawBuffers(); | 900 GLint maxDrawBuffers(); |
| 901 GLint maxColorAttachments(); | 901 GLint maxColorAttachments(); |
| 902 | 902 |
| 903 void setBackDrawBuffer(GLenum); | 903 void setBackDrawBuffer(GLenum); |
| 904 | 904 |
| 905 void restoreCurrentFramebuffer(); | 905 void restoreCurrentFramebuffer(); |
| 906 void restoreCurrentTexture2D(); | 906 void restoreCurrentTexture2D(); |
| 907 | 907 |
| 908 virtual void multisamplingChanged(bool); | 908 virtual void multisamplingChanged(bool) OVERRIDE; |
| 909 | 909 |
| 910 void findNewMaxEnabledAttribIndex(); | 910 void findNewMaxEnabledAttribIndex(); |
| 911 void findNewMaxNonDefaultTextureUnit(); | 911 void findNewMaxNonDefaultTextureUnit(); |
| 912 | 912 |
| 913 friend class WebGLStateRestorer; | 913 friend class WebGLStateRestorer; |
| 914 friend class WebGLRenderingContextEvictionManager; | 914 friend class WebGLRenderingContextEvictionManager; |
| 915 | 915 |
| 916 static Vector<WebGLRenderingContext*>& activeContexts(); | 916 static Vector<WebGLRenderingContext*>& activeContexts(); |
| 917 static Vector<WebGLRenderingContext*>& forciblyEvictedContexts(); | 917 static Vector<WebGLRenderingContext*>& forciblyEvictedContexts(); |
| 918 | 918 |
| 919 static void activateContext(WebGLRenderingContext*); | 919 static void activateContext(WebGLRenderingContext*); |
| 920 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList
); | 920 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList
); |
| 921 static void willDestroyContext(WebGLRenderingContext*); | 921 static void willDestroyContext(WebGLRenderingContext*); |
| 922 static void forciblyLoseOldestContext(const String& reason); | 922 static void forciblyLoseOldestContext(const String& reason); |
| 923 // Return the least recently used context's position in the active context v
ector. | 923 // Return the least recently used context's position in the active context v
ector. |
| 924 // If the vector is empty, return the maximum allowed active context number. | 924 // If the vector is empty, return the maximum allowed active context number. |
| 925 static size_t oldestContextIndex(); | 925 static size_t oldestContextIndex(); |
| 926 static IntSize oldestContextSize(); | 926 static IntSize oldestContextSize(); |
| 927 }; | 927 }; |
| 928 | 928 |
| 929 DEFINE_TYPE_CASTS(WebGLRenderingContext, CanvasRenderingContext, context, contex
t->is3d(), context.is3d()); | 929 DEFINE_TYPE_CASTS(WebGLRenderingContext, CanvasRenderingContext, context, contex
t->is3d(), context.is3d()); |
| 930 | 930 |
| 931 } // namespace WebCore | 931 } // namespace WebCore |
| 932 | 932 |
| 933 #endif | 933 #endif |
| OLD | NEW |