Chromium Code Reviews| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 #include "core/html/canvas/WebGLDebugRendererInfo.h" | 60 #include "core/html/canvas/WebGLDebugRendererInfo.h" |
| 61 #include "core/html/canvas/WebGLDebugShaders.h" | 61 #include "core/html/canvas/WebGLDebugShaders.h" |
| 62 #include "core/html/canvas/WebGLDepthTexture.h" | 62 #include "core/html/canvas/WebGLDepthTexture.h" |
| 63 #include "core/html/canvas/WebGLDrawBuffers.h" | 63 #include "core/html/canvas/WebGLDrawBuffers.h" |
| 64 #include "core/html/canvas/WebGLFramebuffer.h" | 64 #include "core/html/canvas/WebGLFramebuffer.h" |
| 65 #include "core/html/canvas/WebGLLoseContext.h" | 65 #include "core/html/canvas/WebGLLoseContext.h" |
| 66 #include "core/html/canvas/WebGLProgram.h" | 66 #include "core/html/canvas/WebGLProgram.h" |
| 67 #include "core/html/canvas/WebGLRenderbuffer.h" | 67 #include "core/html/canvas/WebGLRenderbuffer.h" |
| 68 #include "core/html/canvas/WebGLShader.h" | 68 #include "core/html/canvas/WebGLShader.h" |
| 69 #include "core/html/canvas/WebGLShaderPrecisionFormat.h" | 69 #include "core/html/canvas/WebGLShaderPrecisionFormat.h" |
| 70 #include "core/html/canvas/WebGLSharedWebGraphicsContext3D.h" | |
| 70 #include "core/html/canvas/WebGLTexture.h" | 71 #include "core/html/canvas/WebGLTexture.h" |
| 71 #include "core/html/canvas/WebGLUniformLocation.h" | 72 #include "core/html/canvas/WebGLUniformLocation.h" |
| 72 #include "core/inspector/InspectorInstrumentation.h" | 73 #include "core/inspector/InspectorInstrumentation.h" |
| 73 #include "core/loader/FrameLoader.h" | 74 #include "core/loader/FrameLoader.h" |
| 74 #include "core/loader/FrameLoaderClient.h" | 75 #include "core/loader/FrameLoaderClient.h" |
| 75 #include "core/rendering/RenderBox.h" | 76 #include "core/rendering/RenderBox.h" |
| 76 #include "platform/CheckedInt.h" | 77 #include "platform/CheckedInt.h" |
| 77 #include "platform/NotImplemented.h" | 78 #include "platform/NotImplemented.h" |
| 78 #include "platform/RuntimeEnabledFeatures.h" | 79 #include "platform/RuntimeEnabledFeatures.h" |
| 79 #include "platform/geometry/IntSize.h" | 80 #include "platform/geometry/IntSize.h" |
| 80 #include "platform/graphics/GraphicsContext.h" | 81 #include "platform/graphics/GraphicsContext.h" |
| 81 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 82 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 82 #include "platform/graphics/gpu/DrawingBuffer.h" | 83 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 83 #include "public/platform/Platform.h" | 84 #include "public/platform/Platform.h" |
| 84 | 85 |
| 85 #include "wtf/PassOwnPtr.h" | 86 #include "wtf/PassOwnPtr.h" |
| 86 #include "wtf/Uint32Array.h" | 87 #include "wtf/Uint32Array.h" |
| 87 #include "wtf/text/StringBuilder.h" | 88 #include "wtf/text/StringBuilder.h" |
| 88 | 89 |
| 89 namespace WebCore { | 90 namespace WebCore { |
| 90 | 91 |
| 91 const double secondsBetweenRestoreAttempts = 1.0; | 92 const double secondsBetweenRestoreAttempts = 1.0; |
| 92 const int maxGLErrorsAllowedToConsole = 256; | 93 const int maxGLErrorsAllowedToConsole = 256; |
| 93 const unsigned maxGLActiveContexts = 16; | 94 const unsigned maxGLActiveContexts = 16; |
| 94 | 95 |
| 96 // FIXME: Oilpan: static vectors to heap allocated WebGLRenderingContextBase obj ects | |
| 97 // are kept here. This relies on the WebGLRenderingContextBase finalization to | |
| 98 // explicitly retire themselves from these vectors, but it'd be preferable if | |
| 99 // the references were traced as per usual. | |
| 95 Vector<WebGLRenderingContextBase*>& WebGLRenderingContextBase::activeContexts() | 100 Vector<WebGLRenderingContextBase*>& WebGLRenderingContextBase::activeContexts() |
| 96 { | 101 { |
| 97 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContextBase*>, activeContexts, ()); | 102 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContextBase*>, activeContexts, ()); |
| 98 return activeContexts; | 103 return activeContexts; |
| 99 } | 104 } |
| 100 | 105 |
| 101 Vector<WebGLRenderingContextBase*>& WebGLRenderingContextBase::forciblyEvictedCo ntexts() | 106 Vector<WebGLRenderingContextBase*>& WebGLRenderingContextBase::forciblyEvictedCo ntexts() |
| 102 { | 107 { |
| 103 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContextBase*>, forciblyEvictedConte xts, ()); | 108 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContextBase*>, forciblyEvictedConte xts, ()); |
| 104 return forciblyEvictedContexts; | 109 return forciblyEvictedContexts; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 WebGLRenderingContextBase::forciblyLoseOldestContext(reason); | 222 WebGLRenderingContextBase::forciblyLoseOldestContext(reason); |
| 218 }; | 223 }; |
| 219 IntSize oldestContextSize() { | 224 IntSize oldestContextSize() { |
| 220 return WebGLRenderingContextBase::oldestContextSize(); | 225 return WebGLRenderingContextBase::oldestContextSize(); |
| 221 }; | 226 }; |
| 222 }; | 227 }; |
| 223 | 228 |
| 224 namespace { | 229 namespace { |
| 225 | 230 |
| 226 class ScopedDrawingBufferBinder { | 231 class ScopedDrawingBufferBinder { |
| 232 STACK_ALLOCATED(); | |
| 227 public: | 233 public: |
| 228 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) | 234 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) |
| 229 : m_drawingBuffer(drawingBuffer) | 235 : m_drawingBuffer(drawingBuffer) |
| 230 , m_framebufferBinding(framebufferBinding) | 236 , m_framebufferBinding(framebufferBinding) |
| 231 { | 237 { |
| 232 // Commit DrawingBuffer if needed (e.g., for multisampling) | 238 // Commit DrawingBuffer if needed (e.g., for multisampling) |
| 233 if (!m_framebufferBinding && m_drawingBuffer) | 239 if (!m_framebufferBinding && m_drawingBuffer) |
| 234 m_drawingBuffer->commit(); | 240 m_drawingBuffer->commit(); |
| 235 } | 241 } |
| 236 | 242 |
| 237 ~ScopedDrawingBufferBinder() | 243 ~ScopedDrawingBufferBinder() |
| 238 { | 244 { |
| 239 // Restore DrawingBuffer if needed | 245 // Restore DrawingBuffer if needed |
| 240 if (!m_framebufferBinding && m_drawingBuffer) | 246 if (!m_framebufferBinding && m_drawingBuffer) |
| 241 m_drawingBuffer->bind(); | 247 m_drawingBuffer->bind(); |
| 242 } | 248 } |
| 243 | 249 |
| 244 private: | 250 private: |
| 245 DrawingBuffer* m_drawingBuffer; | 251 DrawingBuffer* m_drawingBuffer; |
| 246 WebGLFramebuffer* m_framebufferBinding; | 252 RawPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; |
| 247 }; | 253 }; |
| 248 | 254 |
| 249 Platform3DObject objectOrZero(WebGLObject* object) | 255 Platform3DObject objectOrZero(WebGLObject* object) |
| 250 { | 256 { |
| 251 return object ? object->object() : 0; | 257 return object ? object->object() : 0; |
| 252 } | 258 } |
| 253 | 259 |
| 254 GLint clamp(GLint value, GLint min, GLint max) | 260 GLint clamp(GLint value, GLint min, GLint max) |
| 255 { | 261 { |
| 256 if (value < min) | 262 if (value < min) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 | 467 |
| 462 // Swallow all other characters. Unclear whether we may | 468 // Swallow all other characters. Unclear whether we may |
| 463 // want or need to just emit a space per character to try | 469 // want or need to just emit a space per character to try |
| 464 // to preserve column numbers for debugging purposes. | 470 // to preserve column numbers for debugging purposes. |
| 465 break; | 471 break; |
| 466 } | 472 } |
| 467 } | 473 } |
| 468 } // namespace anonymous | 474 } // namespace anonymous |
| 469 | 475 |
| 470 class ScopedTexture2DRestorer { | 476 class ScopedTexture2DRestorer { |
| 477 STACK_ALLOCATED(); | |
| 471 public: | 478 public: |
| 472 ScopedTexture2DRestorer(WebGLRenderingContextBase* context) | 479 explicit ScopedTexture2DRestorer(WebGLRenderingContextBase* context) |
| 473 : m_context(context) | 480 : m_context(context) |
| 474 { | 481 { |
| 475 } | 482 } |
| 476 | 483 |
| 477 ~ScopedTexture2DRestorer() | 484 ~ScopedTexture2DRestorer() |
| 478 { | 485 { |
| 479 m_context->restoreCurrentTexture2D(); | 486 m_context->restoreCurrentTexture2D(); |
| 480 } | 487 } |
| 481 | 488 |
| 482 private: | 489 private: |
| 483 WebGLRenderingContextBase* m_context; | 490 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
| 484 }; | 491 }; |
| 485 | 492 |
| 486 class WebGLRenderingContextLostCallback : public blink::WebGraphicsContext3D::We bGraphicsContextLostCallback { | 493 class WebGLRenderingContextLostCallback FINAL : public NoBaseWillBeGarbageCollec tedFinalized<WebGLRenderingContextLostCallback>, public blink::WebGraphicsContex t3D::WebGraphicsContextLostCallback { |
| 487 WTF_MAKE_FAST_ALLOCATED; | 494 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 488 public: | 495 public: |
| 489 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* cb) : m_context(cb) { } | 496 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextLostCallback> create(WebG LRenderingContextBase* context) |
| 497 { | |
| 498 return adoptPtrWillBeNoop(new WebGLRenderingContextLostCallback(context) ); | |
| 499 } | |
| 500 | |
| 501 virtual ~WebGLRenderingContextLostCallback() { } | |
| 502 | |
| 490 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext); } | 503 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext); } |
| 491 virtual ~WebGLRenderingContextLostCallback() {} | 504 |
| 505 void trace(Visitor* visitor) | |
| 506 { | |
| 507 visitor->trace(m_context); | |
| 508 } | |
| 509 | |
| 492 private: | 510 private: |
| 493 WebGLRenderingContextBase* m_context; | 511 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* contex t) |
| 512 : m_context(context) { } | |
| 513 | |
| 514 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | |
| 494 }; | 515 }; |
| 495 | 516 |
| 496 class WebGLRenderingContextErrorMessageCallback : public blink::WebGraphicsConte xt3D::WebGraphicsErrorMessageCallback { | 517 class WebGLRenderingContextErrorMessageCallback FINAL : public NoBaseWillBeGarba geCollectedFinalized<WebGLRenderingContextErrorMessageCallback>, public blink::W ebGraphicsContext3D::WebGraphicsErrorMessageCallback { |
| 497 WTF_MAKE_FAST_ALLOCATED; | 518 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 498 public: | 519 public: |
| 499 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase * cb) : m_context(cb) { } | 520 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextErrorMessageCallback> cre ate(WebGLRenderingContextBase* context) |
| 521 { | |
| 522 return adoptPtrWillBeNoop(new WebGLRenderingContextErrorMessageCallback( context)); | |
| 523 } | |
| 524 | |
| 525 virtual ~WebGLRenderingContextErrorMessageCallback() { } | |
| 526 | |
| 500 virtual void onErrorMessage(const blink::WebString& message, blink::WGC3Dint ) | 527 virtual void onErrorMessage(const blink::WebString& message, blink::WGC3Dint ) |
| 501 { | 528 { |
| 502 if (m_context->m_synthesizedErrorsToConsole) | 529 if (m_context->m_synthesizedErrorsToConsole) |
| 503 m_context->printGLErrorToConsole(message); | 530 m_context->printGLErrorToConsole(message); |
| 504 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message); | 531 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message); |
| 505 } | 532 } |
| 506 virtual ~WebGLRenderingContextErrorMessageCallback() { } | 533 |
| 534 void trace(Visitor* visitor) | |
| 535 { | |
| 536 visitor->trace(m_context); | |
| 537 } | |
| 538 | |
| 507 private: | 539 private: |
| 508 WebGLRenderingContextBase* m_context; | 540 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase * context) |
| 541 : m_context(context) { } | |
| 542 | |
| 543 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | |
| 509 }; | 544 }; |
| 510 | 545 |
| 511 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, PassOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* r equestedAttributes) | 546 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, PassOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* r equestedAttributes) |
| 512 : CanvasRenderingContext(passedCanvas) | 547 : CanvasRenderingContext(passedCanvas) |
| 513 , ActiveDOMObject(&passedCanvas->document()) | 548 , ActiveDOMObject(&passedCanvas->document()) |
| 514 , m_drawingBuffer(nullptr) | 549 , m_drawingBuffer(nullptr) |
| 515 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) | 550 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) |
| 516 , m_restoreAllowed(false) | 551 , m_restoreAllowed(false) |
| 517 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 552 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
| 518 , m_generatedImageCache(4) | 553 , m_generatedImageCache(4) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 532 m_contextGroup = WebGLContextGroup::create(); | 567 m_contextGroup = WebGLContextGroup::create(); |
| 533 m_contextGroup->addContext(this); | 568 m_contextGroup->addContext(this); |
| 534 | 569 |
| 535 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 570 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
| 536 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 571 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); |
| 537 | 572 |
| 538 m_drawingBuffer = createDrawingBuffer(context); | 573 m_drawingBuffer = createDrawingBuffer(context); |
| 539 if (!m_drawingBuffer) | 574 if (!m_drawingBuffer) |
| 540 return; | 575 return; |
| 541 | 576 |
| 577 #if ENABLE(OILPAN) | |
| 578 m_sharedWebGraphicsContext3D = WebGLSharedWebGraphicsContext3D::create(m_dra wingBuffer); | |
| 579 #endif | |
| 580 | |
| 542 m_drawingBuffer->bind(); | 581 m_drawingBuffer->bind(); |
| 543 setupFlags(); | 582 setupFlags(); |
| 544 initializeNewContext(); | 583 initializeNewContext(); |
| 545 } | 584 } |
| 546 | 585 |
| 547 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn Ptr<blink::WebGraphicsContext3D> context) | 586 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn Ptr<blink::WebGraphicsContext3D> context) |
| 548 { | 587 { |
| 549 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); | 588 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); |
| 550 | 589 |
| 551 blink::WebGraphicsContext3D::Attributes attrs; | 590 blink::WebGraphicsContext3D::Attributes attrs; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 addContextObject(m_defaultVertexArrayObject.get()); | 657 addContextObject(m_defaultVertexArrayObject.get()); |
| 619 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 658 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 620 | 659 |
| 621 m_vertexAttribValue.resize(m_maxVertexAttribs); | 660 m_vertexAttribValue.resize(m_maxVertexAttribs); |
| 622 | 661 |
| 623 createFallbackBlackTextures1x1(); | 662 createFallbackBlackTextures1x1(); |
| 624 | 663 |
| 625 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 664 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 626 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 665 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 627 | 666 |
| 628 m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallbac k(this)); | 667 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); |
| 629 m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessa geCallback(this)); | 668 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this); |
| 630 | 669 |
| 631 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 670 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
| 632 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 671 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
| 633 | 672 |
| 634 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context. | 673 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context. |
| 635 webContext()->flush(); | 674 webContext()->flush(); |
| 636 | 675 |
| 637 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 676 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
| 638 m_extensionEnabled[i] = false; | 677 m_extensionEnabled[i] = false; |
| 639 | 678 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 671 // Helper function for V8 bindings to identify what version of WebGL a CanvasRen deringContext supports. | 710 // Helper function for V8 bindings to identify what version of WebGL a CanvasRen deringContext supports. |
| 672 unsigned WebGLRenderingContextBase::getWebGLVersion(const CanvasRenderingContext * context) | 711 unsigned WebGLRenderingContextBase::getWebGLVersion(const CanvasRenderingContext * context) |
| 673 { | 712 { |
| 674 if (!context->is3d()) | 713 if (!context->is3d()) |
| 675 return 0; | 714 return 0; |
| 676 return static_cast<const WebGLRenderingContextBase*>(context)->version(); | 715 return static_cast<const WebGLRenderingContextBase*>(context)->version(); |
| 677 } | 716 } |
| 678 | 717 |
| 679 WebGLRenderingContextBase::~WebGLRenderingContextBase() | 718 WebGLRenderingContextBase::~WebGLRenderingContextBase() |
| 680 { | 719 { |
| 720 #if !ENABLE(OILPAN) | |
| 681 // Remove all references to WebGLObjects so if they are the last reference | 721 // Remove all references to WebGLObjects so if they are the last reference |
| 682 // they will be freed before the last context is removed from the context gr oup. | 722 // they will be freed before the last context is removed from the context gr oup. |
| 683 m_boundArrayBuffer = nullptr; | 723 m_boundArrayBuffer = nullptr; |
| 684 m_defaultVertexArrayObject = nullptr; | 724 m_defaultVertexArrayObject = nullptr; |
| 685 m_boundVertexArrayObject = nullptr; | 725 m_boundVertexArrayObject = nullptr; |
| 686 m_vertexAttrib0Buffer = nullptr; | 726 m_vertexAttrib0Buffer = nullptr; |
| 687 m_currentProgram = nullptr; | 727 m_currentProgram = nullptr; |
| 688 m_framebufferBinding = nullptr; | 728 m_framebufferBinding = nullptr; |
| 689 m_renderbufferBinding = nullptr; | 729 m_renderbufferBinding = nullptr; |
| 690 | 730 |
| 691 for (size_t i = 0; i < m_textureUnits.size(); ++i) { | 731 for (size_t i = 0; i < m_textureUnits.size(); ++i) { |
| 692 m_textureUnits[i].m_texture2DBinding = nullptr; | 732 m_textureUnits[i].m_texture2DBinding = nullptr; |
| 693 m_textureUnits[i].m_textureCubeMapBinding = nullptr; | 733 m_textureUnits[i].m_textureCubeMapBinding = nullptr; |
| 694 } | 734 } |
| 695 | 735 |
| 696 m_blackTexture2D = nullptr; | 736 m_blackTexture2D = nullptr; |
| 697 m_blackTextureCubeMap = nullptr; | 737 m_blackTextureCubeMap = nullptr; |
| 698 | 738 |
| 699 detachAndRemoveAllObjects(); | 739 detachAndRemoveAllObjects(); |
| 700 | 740 |
| 701 // release all extensions | 741 // Release all extensions now. |
| 702 for (size_t i = 0; i < m_extensions.size(); ++i) | 742 m_extensions.clear(); |
| 703 delete m_extensions[i]; | 743 #endif |
| 704 | 744 |
| 705 // Context must be removed from the group prior to the destruction of the | 745 // Context must be removed from the group prior to the destruction of the |
| 706 // WebGraphicsContext3D, otherwise shared objects may not be properly delete d. | 746 // WebGraphicsContext3D, otherwise shared objects may not be properly delete d. |
| 707 m_contextGroup->removeContext(this); | 747 m_contextGroup->removeContext(this); |
| 708 | 748 |
| 709 destroyContext(); | 749 destroyContext(); |
| 710 | 750 |
| 711 #if !ENABLE(OILPAN) | 751 #if !ENABLE(OILPAN) |
| 712 if (m_multisamplingObserverRegistered) { | 752 if (m_multisamplingObserverRegistered) |
| 713 Page* page = canvas()->document().page(); | 753 if (Page* page = canvas()->document().page()) |
| 714 if (page) | |
| 715 page->removeMultisamplingChangedObserver(this); | 754 page->removeMultisamplingChangedObserver(this); |
| 716 } | |
| 717 #endif | 755 #endif |
| 718 | 756 |
| 719 willDestroyContext(this); | 757 willDestroyContext(this); |
| 720 } | 758 } |
| 721 | 759 |
| 722 void WebGLRenderingContextBase::destroyContext() | 760 void WebGLRenderingContextBase::destroyContext() |
| 723 { | 761 { |
| 724 m_contextLost = true; | 762 m_contextLost = true; |
| 725 | 763 |
| 726 if (!m_drawingBuffer) | 764 if (!m_drawingBuffer) |
| 727 return; | 765 return; |
| 728 | 766 |
| 729 m_extensionsUtil.clear(); | 767 m_extensionsUtil.clear(); |
| 730 | 768 |
| 731 webContext()->setContextLostCallback(0); | 769 webContext()->setContextLostCallback(0); |
| 732 webContext()->setErrorMessageCallback(0); | 770 webContext()->setErrorMessageCallback(0); |
| 733 | 771 |
| 734 ASSERT(m_drawingBuffer); | 772 ASSERT(m_drawingBuffer); |
| 773 #if ENABLE(OILPAN) | |
| 774 // The DrawingBuffer ref pointers are cleared, but the | |
| 775 // WebGLSharedWebGraphicsContext3D object will hold onto the | |
| 776 // DrawingBuffer for as long as needed (== until all | |
| 777 // context objects have been finalized), at which point | |
| 778 // DrawingBuffer destruction happens. | |
| 779 m_drawingBuffer.clear(); | |
| 780 m_sharedWebGraphicsContext3D.clear(); | |
|
haraken
2014/07/15 15:04:56
Just to confirm: This can drop the last ref to the
sof
2014/07/15 16:23:00
None; this is where it happens non-Oilpan (right b
| |
| 781 #else | |
| 735 m_drawingBuffer->beginDestruction(); | 782 m_drawingBuffer->beginDestruction(); |
| 736 m_drawingBuffer.clear(); | 783 m_drawingBuffer.clear(); |
| 784 #endif | |
| 737 } | 785 } |
| 738 | 786 |
| 739 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) | 787 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) |
| 740 { | 788 { |
| 741 if (m_framebufferBinding || isContextLost()) | 789 if (m_framebufferBinding || isContextLost()) |
| 742 return; | 790 return; |
| 743 | 791 |
| 744 m_drawingBuffer->markContentsChanged(); | 792 m_drawingBuffer->markContentsChanged(); |
| 745 | 793 |
| 746 m_layerCleared = false; | 794 m_layerCleared = false; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 759 | 807 |
| 760 bool WebGLRenderingContextBase::clearIfComposited(GLbitfield mask) | 808 bool WebGLRenderingContextBase::clearIfComposited(GLbitfield mask) |
| 761 { | 809 { |
| 762 if (isContextLost()) | 810 if (isContextLost()) |
| 763 return false; | 811 return false; |
| 764 | 812 |
| 765 if (!m_drawingBuffer->layerComposited() || m_layerCleared | 813 if (!m_drawingBuffer->layerComposited() || m_layerCleared |
| 766 || m_requestedAttributes->preserveDrawingBuffer() || (mask && m_framebuf ferBinding)) | 814 || m_requestedAttributes->preserveDrawingBuffer() || (mask && m_framebuf ferBinding)) |
| 767 return false; | 815 return false; |
| 768 | 816 |
| 769 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); | 817 RefPtrWillBeRawPtr<WebGLContextAttributes> contextAttributes = getContextAtt ributes(); |
| 770 | 818 |
| 771 // Determine if it's possible to combine the clear the user asked for and th is clear. | 819 // Determine if it's possible to combine the clear the user asked for and th is clear. |
| 772 bool combinedClear = mask && !m_scissorEnabled; | 820 bool combinedClear = mask && !m_scissorEnabled; |
| 773 | 821 |
| 774 webContext()->disable(GL_SCISSOR_TEST); | 822 webContext()->disable(GL_SCISSOR_TEST); |
| 775 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { | 823 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { |
| 776 webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 824 webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, |
| 777 m_colorMask[1] ? m_clearColor[1] : 0, | 825 m_colorMask[1] ? m_clearColor[1] : 0, |
| 778 m_colorMask[2] ? m_clearColor[2] : 0, | 826 m_colorMask[2] ? m_clearColor[2] : 0, |
| 779 m_colorMask[3] ? m_clearColor[3] : 0); | 827 m_colorMask[3] ? m_clearColor[3] : 0); |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1486 const char* reason = "framebuffer incomplete"; | 1534 const char* reason = "framebuffer incomplete"; |
| 1487 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 1535 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { |
| 1488 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason); | 1536 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason); |
| 1489 return; | 1537 return; |
| 1490 } | 1538 } |
| 1491 clearIfComposited(); | 1539 clearIfComposited(); |
| 1492 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); | 1540 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); |
| 1493 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height); | 1541 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height); |
| 1494 } | 1542 } |
| 1495 | 1543 |
| 1496 PassRefPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() | 1544 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() |
| 1497 { | 1545 { |
| 1498 if (isContextLost()) | 1546 if (isContextLost()) |
| 1499 return nullptr; | 1547 return nullptr; |
| 1500 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); | 1548 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); |
| 1501 addSharedObject(o.get()); | 1549 addSharedObject(o.get()); |
| 1502 return o; | 1550 return o.release(); |
| 1503 } | 1551 } |
| 1504 | 1552 |
| 1505 PassRefPtr<WebGLFramebuffer> WebGLRenderingContextBase::createFramebuffer() | 1553 PassRefPtrWillBeRawPtr<WebGLFramebuffer> WebGLRenderingContextBase::createFrameb uffer() |
| 1506 { | 1554 { |
| 1507 if (isContextLost()) | 1555 if (isContextLost()) |
| 1508 return nullptr; | 1556 return nullptr; |
| 1509 RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); | 1557 RefPtrWillBeRawPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); |
| 1510 addContextObject(o.get()); | 1558 addContextObject(o.get()); |
| 1511 return o; | 1559 return o.release(); |
| 1512 } | 1560 } |
| 1513 | 1561 |
| 1514 PassRefPtr<WebGLTexture> WebGLRenderingContextBase::createTexture() | 1562 PassRefPtrWillBeRawPtr<WebGLTexture> WebGLRenderingContextBase::createTexture() |
| 1515 { | 1563 { |
| 1516 if (isContextLost()) | 1564 if (isContextLost()) |
| 1517 return nullptr; | 1565 return nullptr; |
| 1518 RefPtr<WebGLTexture> o = WebGLTexture::create(this); | 1566 RefPtrWillBeRawPtr<WebGLTexture> o = WebGLTexture::create(this); |
| 1519 addSharedObject(o.get()); | 1567 addSharedObject(o.get()); |
| 1520 return o; | 1568 return o.release(); |
| 1521 } | 1569 } |
| 1522 | 1570 |
| 1523 PassRefPtr<WebGLProgram> WebGLRenderingContextBase::createProgram() | 1571 PassRefPtrWillBeRawPtr<WebGLProgram> WebGLRenderingContextBase::createProgram() |
| 1524 { | 1572 { |
| 1525 if (isContextLost()) | 1573 if (isContextLost()) |
| 1526 return nullptr; | 1574 return nullptr; |
| 1527 RefPtr<WebGLProgram> o = WebGLProgram::create(this); | 1575 RefPtrWillBeRawPtr<WebGLProgram> o = WebGLProgram::create(this); |
| 1528 addSharedObject(o.get()); | 1576 addSharedObject(o.get()); |
| 1529 return o; | 1577 return o.release(); |
| 1530 } | 1578 } |
| 1531 | 1579 |
| 1532 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContextBase::createRenderbuffer() | 1580 PassRefPtrWillBeRawPtr<WebGLRenderbuffer> WebGLRenderingContextBase::createRende rbuffer() |
| 1533 { | 1581 { |
| 1534 if (isContextLost()) | 1582 if (isContextLost()) |
| 1535 return nullptr; | 1583 return nullptr; |
| 1536 RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); | 1584 RefPtrWillBeRawPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); |
| 1537 addSharedObject(o.get()); | 1585 addSharedObject(o.get()); |
| 1538 return o; | 1586 return o.release(); |
| 1539 } | 1587 } |
| 1540 | 1588 |
| 1541 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuffer* renderbuffer) | 1589 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuffer* renderbuffer) |
| 1542 { | 1590 { |
| 1543 if (isContextLost()) | 1591 if (isContextLost()) |
| 1544 return 0; | 1592 return 0; |
| 1545 if (!renderbuffer->emulatedStencilBuffer()) { | 1593 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1546 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1594 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1547 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); | 1595 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); |
| 1548 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); | 1596 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); |
| 1549 } | 1597 } |
| 1550 return renderbuffer->emulatedStencilBuffer(); | 1598 return renderbuffer->emulatedStencilBuffer(); |
| 1551 } | 1599 } |
| 1552 | 1600 |
| 1553 PassRefPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLenum type) | 1601 PassRefPtrWillBeRawPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLen um type) |
| 1554 { | 1602 { |
| 1555 if (isContextLost()) | 1603 if (isContextLost()) |
| 1556 return nullptr; | 1604 return nullptr; |
| 1557 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1605 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1558 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); | 1606 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); |
| 1559 return nullptr; | 1607 return nullptr; |
| 1560 } | 1608 } |
| 1561 | 1609 |
| 1562 RefPtr<WebGLShader> o = WebGLShader::create(this, type); | 1610 RefPtrWillBeRawPtr<WebGLShader> o = WebGLShader::create(this, type); |
| 1563 addSharedObject(o.get()); | 1611 addSharedObject(o.get()); |
| 1564 return o; | 1612 return o.release(); |
| 1565 } | 1613 } |
| 1566 | 1614 |
| 1567 void WebGLRenderingContextBase::cullFace(GLenum mode) | 1615 void WebGLRenderingContextBase::cullFace(GLenum mode) |
| 1568 { | 1616 { |
| 1569 if (isContextLost()) | 1617 if (isContextLost()) |
| 1570 return; | 1618 return; |
| 1571 switch (mode) { | 1619 switch (mode) { |
| 1572 case GL_FRONT_AND_BACK: | 1620 case GL_FRONT_AND_BACK: |
| 1573 case GL_FRONT: | 1621 case GL_FRONT: |
| 1574 case GL_BACK: | 1622 case GL_BACK: |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2000 } | 2048 } |
| 2001 #endif | 2049 #endif |
| 2002 webContext()->generateMipmap(target); | 2050 webContext()->generateMipmap(target); |
| 2003 #if OS(MACOSX) | 2051 #if OS(MACOSX) |
| 2004 if (needToResetMinFilter) | 2052 if (needToResetMinFilter) |
| 2005 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFi lter()); | 2053 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFi lter()); |
| 2006 #endif | 2054 #endif |
| 2007 tex->generateMipmapLevelInfo(); | 2055 tex->generateMipmapLevelInfo(); |
| 2008 } | 2056 } |
| 2009 | 2057 |
| 2010 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg ram* program, GLuint index) | 2058 PassRefPtrWillBeRawPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttr ib(WebGLProgram* program, GLuint index) |
| 2011 { | 2059 { |
| 2012 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2060 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2013 return nullptr; | 2061 return nullptr; |
| 2014 blink::WebGraphicsContext3D::ActiveInfo info; | 2062 blink::WebGraphicsContext3D::ActiveInfo info; |
| 2015 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) | 2063 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) |
| 2016 return nullptr; | 2064 return nullptr; |
| 2017 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2065 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2018 } | 2066 } |
| 2019 | 2067 |
| 2020 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLPro gram* program, GLuint index) | 2068 PassRefPtrWillBeRawPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUnif orm(WebGLProgram* program, GLuint index) |
| 2021 { | 2069 { |
| 2022 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 2070 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) |
| 2023 return nullptr; | 2071 return nullptr; |
| 2024 blink::WebGraphicsContext3D::ActiveInfo info; | 2072 blink::WebGraphicsContext3D::ActiveInfo info; |
| 2025 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) | 2073 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) |
| 2026 return nullptr; | 2074 return nullptr; |
| 2027 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2075 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2028 } | 2076 } |
| 2029 | 2077 |
| 2030 Nullable<Vector<RefPtr<WebGLShader> > > WebGLRenderingContextBase::getAttachedSh aders(WebGLProgram* program) | 2078 Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > > WebGLRenderingCont extBase::getAttachedShaders(WebGLProgram* program) |
| 2031 { | 2079 { |
| 2032 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 2080 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
| 2033 return Nullable<Vector<RefPtr<WebGLShader> > >(); | 2081 return Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > >(); |
| 2034 | 2082 |
| 2035 Vector<RefPtr<WebGLShader> > shaderObjects; | 2083 WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > shaderObjects; |
| 2036 const GLenum shaderType[] = { | 2084 const GLenum shaderType[] = { |
| 2037 GL_VERTEX_SHADER, | 2085 GL_VERTEX_SHADER, |
| 2038 GL_FRAGMENT_SHADER | 2086 GL_FRAGMENT_SHADER |
| 2039 }; | 2087 }; |
| 2040 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GLenum); ++i) { | 2088 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GLenum); ++i) { |
| 2041 WebGLShader* shader = program->getAttachedShader(shaderType[i]); | 2089 WebGLShader* shader = program->getAttachedShader(shaderType[i]); |
| 2042 if (shader) | 2090 if (shader) |
| 2043 shaderObjects.append(shader); | 2091 shaderObjects.append(shader); |
| 2044 } | 2092 } |
| 2045 return shaderObjects; | 2093 return shaderObjects; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2076 return WebGLGetInfo(); | 2124 return WebGLGetInfo(); |
| 2077 } | 2125 } |
| 2078 | 2126 |
| 2079 GLint value = 0; | 2127 GLint value = 0; |
| 2080 webContext()->getBufferParameteriv(target, pname, &value); | 2128 webContext()->getBufferParameteriv(target, pname, &value); |
| 2081 if (pname == GL_BUFFER_SIZE) | 2129 if (pname == GL_BUFFER_SIZE) |
| 2082 return WebGLGetInfo(value); | 2130 return WebGLGetInfo(value); |
| 2083 return WebGLGetInfo(static_cast<unsigned>(value)); | 2131 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2084 } | 2132 } |
| 2085 | 2133 |
| 2086 PassRefPtr<WebGLContextAttributes> WebGLRenderingContextBase::getContextAttribut es() | 2134 PassRefPtrWillBeRawPtr<WebGLContextAttributes> WebGLRenderingContextBase::getCon textAttributes() |
| 2087 { | 2135 { |
| 2088 if (isContextLost()) | 2136 if (isContextLost()) |
| 2089 return nullptr; | 2137 return nullptr; |
| 2090 // We always need to return a new WebGLContextAttributes object to | 2138 // We always need to return a new WebGLContextAttributes object to |
| 2091 // prevent the user from mutating any cached version. | 2139 // prevent the user from mutating any cached version. |
| 2092 blink::WebGraphicsContext3D::Attributes attrs = m_drawingBuffer->getActualAt tributes(); | 2140 blink::WebGraphicsContext3D::Attributes attrs = m_drawingBuffer->getActualAt tributes(); |
| 2093 RefPtr<WebGLContextAttributes> attributes = m_requestedAttributes->clone(); | 2141 RefPtrWillBeRawPtr<WebGLContextAttributes> attributes = m_requestedAttribute s->clone(); |
| 2094 // Some requested attributes may not be honored, so we need to query the und erlying | 2142 // Some requested attributes may not be honored, so we need to query the und erlying |
| 2095 // context/drawing buffer and adjust accordingly. | 2143 // context/drawing buffer and adjust accordingly. |
| 2096 if (m_requestedAttributes->depth() && !attrs.depth) | 2144 if (m_requestedAttributes->depth() && !attrs.depth) |
| 2097 attributes->setDepth(false); | 2145 attributes->setDepth(false); |
| 2098 if (m_requestedAttributes->stencil() && !attrs.stencil) | 2146 if (m_requestedAttributes->stencil() && !attrs.stencil) |
| 2099 attributes->setStencil(false); | 2147 attributes->setStencil(false); |
| 2100 attributes->setAntialias(m_drawingBuffer->multisample()); | 2148 attributes->setAntialias(m_drawingBuffer->multisample()); |
| 2101 return attributes.release(); | 2149 return attributes.release(); |
| 2102 } | 2150 } |
| 2103 | 2151 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2136 bool WebGLRenderingContextBase::extensionSupportedAndAllowed(const ExtensionTrac ker* tracker) | 2184 bool WebGLRenderingContextBase::extensionSupportedAndAllowed(const ExtensionTrac ker* tracker) |
| 2137 { | 2185 { |
| 2138 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) | 2186 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) |
| 2139 return false; | 2187 return false; |
| 2140 if (!tracker->supported(this)) | 2188 if (!tracker->supported(this)) |
| 2141 return false; | 2189 return false; |
| 2142 return true; | 2190 return true; |
| 2143 } | 2191 } |
| 2144 | 2192 |
| 2145 | 2193 |
| 2146 PassRefPtr<WebGLExtension> WebGLRenderingContextBase::getExtension(const String& name) | 2194 PassRefPtrWillBeRawPtr<WebGLExtension> WebGLRenderingContextBase::getExtension(c onst String& name) |
| 2147 { | 2195 { |
| 2148 if (isContextLost()) | 2196 if (isContextLost()) |
| 2149 return nullptr; | 2197 return nullptr; |
| 2150 | 2198 |
| 2151 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2199 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2152 ExtensionTracker* tracker = m_extensions[i]; | 2200 ExtensionTracker* tracker = m_extensions[i].get(); |
| 2153 if (tracker->matchesNameWithPrefixes(name)) { | 2201 if (tracker->matchesNameWithPrefixes(name)) { |
| 2154 if (!extensionSupportedAndAllowed(tracker)) | 2202 if (!extensionSupportedAndAllowed(tracker)) |
| 2155 return nullptr; | 2203 return nullptr; |
| 2156 | 2204 |
| 2157 RefPtr<WebGLExtension> extension = tracker->getExtension(this); | 2205 RefPtrWillBeRawPtr<WebGLExtension> extension = tracker->getExtension (this); |
| 2158 if (extension) | 2206 if (extension) |
| 2159 m_extensionEnabled[extension->name()] = true; | 2207 m_extensionEnabled[extension->name()] = true; |
| 2160 return extension.release(); | 2208 return extension.release(); |
| 2161 } | 2209 } |
| 2162 } | 2210 } |
| 2163 | 2211 |
| 2164 return nullptr; | 2212 return nullptr; |
| 2165 } | 2213 } |
| 2166 | 2214 |
| 2167 WebGLGetInfo WebGLRenderingContextBase::getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname) | 2215 WebGLGetInfo WebGLRenderingContextBase::getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2183 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); | 2231 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); |
| 2184 return WebGLGetInfo(); | 2232 return WebGLGetInfo(); |
| 2185 } | 2233 } |
| 2186 | 2234 |
| 2187 ASSERT(object->isTexture() || object->isRenderbuffer()); | 2235 ASSERT(object->isTexture() || object->isRenderbuffer()); |
| 2188 if (object->isTexture()) { | 2236 if (object->isTexture()) { |
| 2189 switch (pname) { | 2237 switch (pname) { |
| 2190 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2238 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2191 return WebGLGetInfo(GL_TEXTURE); | 2239 return WebGLGetInfo(GL_TEXTURE); |
| 2192 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2240 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2193 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur e*>(object))); | 2241 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLTexture>(static_cast <WebGLTexture*>(object))); |
| 2194 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | 2242 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2195 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | 2243 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2196 { | 2244 { |
| 2197 GLint value = 0; | 2245 GLint value = 0; |
| 2198 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); | 2246 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); |
| 2199 return WebGLGetInfo(value); | 2247 return WebGLGetInfo(value); |
| 2200 } | 2248 } |
| 2201 default: | 2249 default: |
| 2202 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); | 2250 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); |
| 2203 return WebGLGetInfo(); | 2251 return WebGLGetInfo(); |
| 2204 } | 2252 } |
| 2205 } else { | 2253 } else { |
| 2206 switch (pname) { | 2254 switch (pname) { |
| 2207 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2255 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2208 return WebGLGetInfo(GL_RENDERBUFFER); | 2256 return WebGLGetInfo(GL_RENDERBUFFER); |
| 2209 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2257 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2210 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR enderbuffer*>(object))); | 2258 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLRenderbuffer>(static _cast<WebGLRenderbuffer*>(object))); |
| 2211 default: | 2259 default: |
| 2212 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); | 2260 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); |
| 2213 return WebGLGetInfo(); | 2261 return WebGLGetInfo(); |
| 2214 } | 2262 } |
| 2215 } | 2263 } |
| 2216 } | 2264 } |
| 2217 | 2265 |
| 2218 WebGLGetInfo WebGLRenderingContextBase::getParameter(GLenum pname) | 2266 WebGLGetInfo WebGLRenderingContextBase::getParameter(GLenum pname) |
| 2219 { | 2267 { |
| 2220 if (isContextLost()) | 2268 if (isContextLost()) |
| 2221 return WebGLGetInfo(); | 2269 return WebGLGetInfo(); |
| 2222 const int intZero = 0; | 2270 const int intZero = 0; |
| 2223 switch (pname) { | 2271 switch (pname) { |
| 2224 case GL_ACTIVE_TEXTURE: | 2272 case GL_ACTIVE_TEXTURE: |
| 2225 return getUnsignedIntParameter(pname); | 2273 return getUnsignedIntParameter(pname); |
| 2226 case GL_ALIASED_LINE_WIDTH_RANGE: | 2274 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 2227 return getWebGLFloatArrayParameter(pname); | 2275 return getWebGLFloatArrayParameter(pname); |
| 2228 case GL_ALIASED_POINT_SIZE_RANGE: | 2276 case GL_ALIASED_POINT_SIZE_RANGE: |
| 2229 return getWebGLFloatArrayParameter(pname); | 2277 return getWebGLFloatArrayParameter(pname); |
| 2230 case GL_ALPHA_BITS: | 2278 case GL_ALPHA_BITS: |
| 2231 return getIntParameter(pname); | 2279 return getIntParameter(pname); |
| 2232 case GL_ARRAY_BUFFER_BINDING: | 2280 case GL_ARRAY_BUFFER_BINDING: |
| 2233 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundArrayBuffer)); | 2281 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLBuffer>(m_boundArrayBuff er.get())); |
| 2234 case GL_BLEND: | 2282 case GL_BLEND: |
| 2235 return getBooleanParameter(pname); | 2283 return getBooleanParameter(pname); |
| 2236 case GL_BLEND_COLOR: | 2284 case GL_BLEND_COLOR: |
| 2237 return getWebGLFloatArrayParameter(pname); | 2285 return getWebGLFloatArrayParameter(pname); |
| 2238 case GL_BLEND_DST_ALPHA: | 2286 case GL_BLEND_DST_ALPHA: |
| 2239 return getUnsignedIntParameter(pname); | 2287 return getUnsignedIntParameter(pname); |
| 2240 case GL_BLEND_DST_RGB: | 2288 case GL_BLEND_DST_RGB: |
| 2241 return getUnsignedIntParameter(pname); | 2289 return getUnsignedIntParameter(pname); |
| 2242 case GL_BLEND_EQUATION_ALPHA: | 2290 case GL_BLEND_EQUATION_ALPHA: |
| 2243 return getUnsignedIntParameter(pname); | 2291 return getUnsignedIntParameter(pname); |
| 2244 case GL_BLEND_EQUATION_RGB: | 2292 case GL_BLEND_EQUATION_RGB: |
| 2245 return getUnsignedIntParameter(pname); | 2293 return getUnsignedIntParameter(pname); |
| 2246 case GL_BLEND_SRC_ALPHA: | 2294 case GL_BLEND_SRC_ALPHA: |
| 2247 return getUnsignedIntParameter(pname); | 2295 return getUnsignedIntParameter(pname); |
| 2248 case GL_BLEND_SRC_RGB: | 2296 case GL_BLEND_SRC_RGB: |
| 2249 return getUnsignedIntParameter(pname); | 2297 return getUnsignedIntParameter(pname); |
| 2250 case GL_BLUE_BITS: | 2298 case GL_BLUE_BITS: |
| 2251 return getIntParameter(pname); | 2299 return getIntParameter(pname); |
| 2252 case GL_COLOR_CLEAR_VALUE: | 2300 case GL_COLOR_CLEAR_VALUE: |
| 2253 return getWebGLFloatArrayParameter(pname); | 2301 return getWebGLFloatArrayParameter(pname); |
| 2254 case GL_COLOR_WRITEMASK: | 2302 case GL_COLOR_WRITEMASK: |
| 2255 return getBooleanArrayParameter(pname); | 2303 return getBooleanArrayParameter(pname); |
| 2256 case GL_COMPRESSED_TEXTURE_FORMATS: | 2304 case GL_COMPRESSED_TEXTURE_FORMATS: |
| 2257 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data( ), m_compressedTextureFormats.size())); | 2305 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data( ), m_compressedTextureFormats.size())); |
| 2258 case GL_CULL_FACE: | 2306 case GL_CULL_FACE: |
| 2259 return getBooleanParameter(pname); | 2307 return getBooleanParameter(pname); |
| 2260 case GL_CULL_FACE_MODE: | 2308 case GL_CULL_FACE_MODE: |
| 2261 return getUnsignedIntParameter(pname); | 2309 return getUnsignedIntParameter(pname); |
| 2262 case GL_CURRENT_PROGRAM: | 2310 case GL_CURRENT_PROGRAM: |
| 2263 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram)); | 2311 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLProgram>(m_currentProgra m.get())); |
| 2264 case GL_DEPTH_BITS: | 2312 case GL_DEPTH_BITS: |
| 2265 if (!m_framebufferBinding && !m_requestedAttributes->depth()) | 2313 if (!m_framebufferBinding && !m_requestedAttributes->depth()) |
| 2266 return WebGLGetInfo(intZero); | 2314 return WebGLGetInfo(intZero); |
| 2267 return getIntParameter(pname); | 2315 return getIntParameter(pname); |
| 2268 case GL_DEPTH_CLEAR_VALUE: | 2316 case GL_DEPTH_CLEAR_VALUE: |
| 2269 return getFloatParameter(pname); | 2317 return getFloatParameter(pname); |
| 2270 case GL_DEPTH_FUNC: | 2318 case GL_DEPTH_FUNC: |
| 2271 return getUnsignedIntParameter(pname); | 2319 return getUnsignedIntParameter(pname); |
| 2272 case GL_DEPTH_RANGE: | 2320 case GL_DEPTH_RANGE: |
| 2273 return getWebGLFloatArrayParameter(pname); | 2321 return getWebGLFloatArrayParameter(pname); |
| 2274 case GL_DEPTH_TEST: | 2322 case GL_DEPTH_TEST: |
| 2275 return getBooleanParameter(pname); | 2323 return getBooleanParameter(pname); |
| 2276 case GL_DEPTH_WRITEMASK: | 2324 case GL_DEPTH_WRITEMASK: |
| 2277 return getBooleanParameter(pname); | 2325 return getBooleanParameter(pname); |
| 2278 case GL_DITHER: | 2326 case GL_DITHER: |
| 2279 return getBooleanParameter(pname); | 2327 return getBooleanParameter(pname); |
| 2280 case GL_ELEMENT_ARRAY_BUFFER_BINDING: | 2328 case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 2281 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundVertexArrayObject->bo undElementArrayBuffer())); | 2329 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLBuffer>(m_boundVertexArr ayObject->boundElementArrayBuffer())); |
| 2282 case GL_FRAMEBUFFER_BINDING: | 2330 case GL_FRAMEBUFFER_BINDING: |
| 2283 return WebGLGetInfo(PassRefPtr<WebGLFramebuffer>(m_framebufferBinding)); | 2331 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLFramebuffer>(m_framebuff erBinding.get())); |
| 2284 case GL_FRONT_FACE: | 2332 case GL_FRONT_FACE: |
| 2285 return getUnsignedIntParameter(pname); | 2333 return getUnsignedIntParameter(pname); |
| 2286 case GL_GENERATE_MIPMAP_HINT: | 2334 case GL_GENERATE_MIPMAP_HINT: |
| 2287 return getUnsignedIntParameter(pname); | 2335 return getUnsignedIntParameter(pname); |
| 2288 case GL_GREEN_BITS: | 2336 case GL_GREEN_BITS: |
| 2289 return getIntParameter(pname); | 2337 return getIntParameter(pname); |
| 2290 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: | 2338 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 2291 return getIntParameter(pname); | 2339 return getIntParameter(pname); |
| 2292 case GL_IMPLEMENTATION_COLOR_READ_TYPE: | 2340 case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 2293 return getIntParameter(pname); | 2341 return getIntParameter(pname); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2322 return getIntParameter(pname); | 2370 return getIntParameter(pname); |
| 2323 case GL_POLYGON_OFFSET_FACTOR: | 2371 case GL_POLYGON_OFFSET_FACTOR: |
| 2324 return getFloatParameter(pname); | 2372 return getFloatParameter(pname); |
| 2325 case GL_POLYGON_OFFSET_FILL: | 2373 case GL_POLYGON_OFFSET_FILL: |
| 2326 return getBooleanParameter(pname); | 2374 return getBooleanParameter(pname); |
| 2327 case GL_POLYGON_OFFSET_UNITS: | 2375 case GL_POLYGON_OFFSET_UNITS: |
| 2328 return getFloatParameter(pname); | 2376 return getFloatParameter(pname); |
| 2329 case GL_RED_BITS: | 2377 case GL_RED_BITS: |
| 2330 return getIntParameter(pname); | 2378 return getIntParameter(pname); |
| 2331 case GL_RENDERBUFFER_BINDING: | 2379 case GL_RENDERBUFFER_BINDING: |
| 2332 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(m_renderbufferBinding) ); | 2380 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLRenderbuffer>(m_renderbu fferBinding.get())); |
| 2333 case GL_RENDERER: | 2381 case GL_RENDERER: |
| 2334 return WebGLGetInfo(String("WebKit WebGL")); | 2382 return WebGLGetInfo(String("WebKit WebGL")); |
| 2335 case GL_SAMPLE_BUFFERS: | 2383 case GL_SAMPLE_BUFFERS: |
| 2336 return getIntParameter(pname); | 2384 return getIntParameter(pname); |
| 2337 case GL_SAMPLE_COVERAGE_INVERT: | 2385 case GL_SAMPLE_COVERAGE_INVERT: |
| 2338 return getBooleanParameter(pname); | 2386 return getBooleanParameter(pname); |
| 2339 case GL_SAMPLE_COVERAGE_VALUE: | 2387 case GL_SAMPLE_COVERAGE_VALUE: |
| 2340 return getFloatParameter(pname); | 2388 return getFloatParameter(pname); |
| 2341 case GL_SAMPLES: | 2389 case GL_SAMPLES: |
| 2342 return getIntParameter(pname); | 2390 return getIntParameter(pname); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2378 return getIntParameter(pname); | 2426 return getIntParameter(pname); |
| 2379 case GL_STENCIL_TEST: | 2427 case GL_STENCIL_TEST: |
| 2380 return getBooleanParameter(pname); | 2428 return getBooleanParameter(pname); |
| 2381 case GL_STENCIL_VALUE_MASK: | 2429 case GL_STENCIL_VALUE_MASK: |
| 2382 return getUnsignedIntParameter(pname); | 2430 return getUnsignedIntParameter(pname); |
| 2383 case GL_STENCIL_WRITEMASK: | 2431 case GL_STENCIL_WRITEMASK: |
| 2384 return getUnsignedIntParameter(pname); | 2432 return getUnsignedIntParameter(pname); |
| 2385 case GL_SUBPIXEL_BITS: | 2433 case GL_SUBPIXEL_BITS: |
| 2386 return getIntParameter(pname); | 2434 return getIntParameter(pname); |
| 2387 case GL_TEXTURE_BINDING_2D: | 2435 case GL_TEXTURE_BINDING_2D: |
| 2388 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText ureUnit].m_texture2DBinding)); | 2436 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLTexture>(m_textureUnits[ m_activeTextureUnit].m_texture2DBinding.get())); |
| 2389 case GL_TEXTURE_BINDING_CUBE_MAP: | 2437 case GL_TEXTURE_BINDING_CUBE_MAP: |
| 2390 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText ureUnit].m_textureCubeMapBinding)); | 2438 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLTexture>(m_textureUnits[ m_activeTextureUnit].m_textureCubeMapBinding.get())); |
| 2391 case GL_UNPACK_ALIGNMENT: | 2439 case GL_UNPACK_ALIGNMENT: |
| 2392 return getIntParameter(pname); | 2440 return getIntParameter(pname); |
| 2393 case GC3D_UNPACK_FLIP_Y_WEBGL: | 2441 case GC3D_UNPACK_FLIP_Y_WEBGL: |
| 2394 return WebGLGetInfo(m_unpackFlipY); | 2442 return WebGLGetInfo(m_unpackFlipY); |
| 2395 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: | 2443 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: |
| 2396 return WebGLGetInfo(m_unpackPremultiplyAlpha); | 2444 return WebGLGetInfo(m_unpackPremultiplyAlpha); |
| 2397 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: | 2445 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: |
| 2398 return WebGLGetInfo(m_unpackColorspaceConversion); | 2446 return WebGLGetInfo(m_unpackColorspaceConversion); |
| 2399 case GL_VENDOR: | 2447 case GL_VENDOR: |
| 2400 return WebGLGetInfo(String("WebKit")); | 2448 return WebGLGetInfo(String("WebKit")); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2413 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); | 2461 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); |
| 2414 return WebGLGetInfo(); | 2462 return WebGLGetInfo(); |
| 2415 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: | 2463 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: |
| 2416 if (extensionEnabled(WebGLDebugRendererInfoName)) | 2464 if (extensionEnabled(WebGLDebugRendererInfoName)) |
| 2417 return WebGLGetInfo(webContext()->getString(GL_VENDOR)); | 2465 return WebGLGetInfo(webContext()->getString(GL_VENDOR)); |
| 2418 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); | 2466 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); |
| 2419 return WebGLGetInfo(); | 2467 return WebGLGetInfo(); |
| 2420 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object | 2468 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object |
| 2421 if (extensionEnabled(OESVertexArrayObjectName)) { | 2469 if (extensionEnabled(OESVertexArrayObjectName)) { |
| 2422 if (!m_boundVertexArrayObject->isDefaultObject()) | 2470 if (!m_boundVertexArrayObject->isDefaultObject()) |
| 2423 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject)); | 2471 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLVertexArrayObjec tOES>(m_boundVertexArrayObject.get())); |
| 2424 return WebGLGetInfo(); | 2472 return WebGLGetInfo(); |
| 2425 } | 2473 } |
| 2426 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled"); | 2474 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled"); |
| 2427 return WebGLGetInfo(); | 2475 return WebGLGetInfo(); |
| 2428 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic | 2476 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic |
| 2429 if (extensionEnabled(EXTTextureFilterAnisotropicName)) | 2477 if (extensionEnabled(EXTTextureFilterAnisotropicName)) |
| 2430 return getUnsignedIntParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); | 2478 return getUnsignedIntParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); |
| 2431 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled"); | 2479 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled"); |
| 2432 return WebGLGetInfo(); | 2480 return WebGLGetInfo(); |
| 2433 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN | 2481 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2553 | 2601 |
| 2554 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) | 2602 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) |
| 2555 { | 2603 { |
| 2556 if (isContextLost()) | 2604 if (isContextLost()) |
| 2557 return String(); | 2605 return String(); |
| 2558 if (!validateWebGLObject("getShaderInfoLog", shader)) | 2606 if (!validateWebGLObject("getShaderInfoLog", shader)) |
| 2559 return ""; | 2607 return ""; |
| 2560 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader))); | 2608 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader))); |
| 2561 } | 2609 } |
| 2562 | 2610 |
| 2563 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::getShaderPreci sionFormat(GLenum shaderType, GLenum precisionType) | 2611 PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::ge tShaderPrecisionFormat(GLenum shaderType, GLenum precisionType) |
| 2564 { | 2612 { |
| 2565 if (isContextLost()) | 2613 if (isContextLost()) |
| 2566 return nullptr; | 2614 return nullptr; |
| 2567 switch (shaderType) { | 2615 switch (shaderType) { |
| 2568 case GL_VERTEX_SHADER: | 2616 case GL_VERTEX_SHADER: |
| 2569 case GL_FRAGMENT_SHADER: | 2617 case GL_FRAGMENT_SHADER: |
| 2570 break; | 2618 break; |
| 2571 default: | 2619 default: |
| 2572 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type"); | 2620 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type"); |
| 2573 return nullptr; | 2621 return nullptr; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2601 } | 2649 } |
| 2602 | 2650 |
| 2603 Nullable<Vector<String> > WebGLRenderingContextBase::getSupportedExtensions() | 2651 Nullable<Vector<String> > WebGLRenderingContextBase::getSupportedExtensions() |
| 2604 { | 2652 { |
| 2605 if (isContextLost()) | 2653 if (isContextLost()) |
| 2606 return Nullable<Vector<String> >(); | 2654 return Nullable<Vector<String> >(); |
| 2607 | 2655 |
| 2608 Vector<String> result; | 2656 Vector<String> result; |
| 2609 | 2657 |
| 2610 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2658 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2611 ExtensionTracker* tracker = m_extensions[i]; | 2659 ExtensionTracker* tracker = m_extensions[i].get(); |
| 2612 if (extensionSupportedAndAllowed(tracker)) { | 2660 if (extensionSupportedAndAllowed(tracker)) { |
| 2613 const char* const* prefixes = tracker->prefixes(); | 2661 const char* const* prefixes = tracker->prefixes(); |
| 2614 for (; *prefixes; ++prefixes) { | 2662 for (; *prefixes; ++prefixes) { |
| 2615 String prefixedName = String(*prefixes) + tracker->extensionName (); | 2663 String prefixedName = String(*prefixes) + tracker->extensionName (); |
| 2616 result.append(prefixedName); | 2664 result.append(prefixedName); |
| 2617 } | 2665 } |
| 2618 } | 2666 } |
| 2619 } | 2667 } |
| 2620 | 2668 |
| 2621 return result; | 2669 return result; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2790 notImplemented(); | 2838 notImplemented(); |
| 2791 } | 2839 } |
| 2792 } | 2840 } |
| 2793 } | 2841 } |
| 2794 } | 2842 } |
| 2795 // If we get here, something went wrong in our unfortunately complex logic a bove | 2843 // If we get here, something went wrong in our unfortunately complex logic a bove |
| 2796 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); | 2844 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); |
| 2797 return WebGLGetInfo(); | 2845 return WebGLGetInfo(); |
| 2798 } | 2846 } |
| 2799 | 2847 |
| 2800 PassRefPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUniformLocation(W ebGLProgram* program, const String& name) | 2848 PassRefPtrWillBeRawPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUnifo rmLocation(WebGLProgram* program, const String& name) |
| 2801 { | 2849 { |
| 2802 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) | 2850 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) |
| 2803 return nullptr; | 2851 return nullptr; |
| 2804 if (!validateLocationLength("getUniformLocation", name)) | 2852 if (!validateLocationLength("getUniformLocation", name)) |
| 2805 return nullptr; | 2853 return nullptr; |
| 2806 if (!validateString("getUniformLocation", name)) | 2854 if (!validateString("getUniformLocation", name)) |
| 2807 return nullptr; | 2855 return nullptr; |
| 2808 if (isPrefixReserved(name)) | 2856 if (isPrefixReserved(name)) |
| 2809 return nullptr; | 2857 return nullptr; |
| 2810 if (!program->linkStatus()) { | 2858 if (!program->linkStatus()) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2827 } | 2875 } |
| 2828 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); | 2876 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); |
| 2829 | 2877 |
| 2830 if (extensionEnabled(ANGLEInstancedArraysName) && pname == GL_VERTEX_ATTRIB_ ARRAY_DIVISOR_ANGLE) | 2878 if (extensionEnabled(ANGLEInstancedArraysName) && pname == GL_VERTEX_ATTRIB_ ARRAY_DIVISOR_ANGLE) |
| 2831 return WebGLGetInfo(state.divisor); | 2879 return WebGLGetInfo(state.divisor); |
| 2832 | 2880 |
| 2833 switch (pname) { | 2881 switch (pname) { |
| 2834 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: | 2882 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 2835 if (!state.bufferBinding || !state.bufferBinding->object()) | 2883 if (!state.bufferBinding || !state.bufferBinding->object()) |
| 2836 return WebGLGetInfo(); | 2884 return WebGLGetInfo(); |
| 2837 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); | 2885 return WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLBuffer>(state.bufferBind ing.get())); |
| 2838 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: | 2886 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 2839 return WebGLGetInfo(state.enabled); | 2887 return WebGLGetInfo(state.enabled); |
| 2840 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: | 2888 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 2841 return WebGLGetInfo(state.normalized); | 2889 return WebGLGetInfo(state.normalized); |
| 2842 case GL_VERTEX_ATTRIB_ARRAY_SIZE: | 2890 case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 2843 return WebGLGetInfo(state.size); | 2891 return WebGLGetInfo(state.size); |
| 2844 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: | 2892 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 2845 return WebGLGetInfo(state.originalStride); | 2893 return WebGLGetInfo(state.originalStride); |
| 2846 case GL_VERTEX_ATTRIB_ARRAY_TYPE: | 2894 case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 2847 return WebGLGetInfo(state.type); | 2895 return WebGLGetInfo(state.type); |
| (...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4204 } | 4252 } |
| 4205 | 4253 |
| 4206 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. | 4254 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. |
| 4207 m_drawingBuffer->setTexture2DBinding(0); | 4255 m_drawingBuffer->setTexture2DBinding(0); |
| 4208 m_drawingBuffer->setFramebufferBinding(0); | 4256 m_drawingBuffer->setFramebufferBinding(0); |
| 4209 | 4257 |
| 4210 detachAndRemoveAllObjects(); | 4258 detachAndRemoveAllObjects(); |
| 4211 | 4259 |
| 4212 // Lose all the extensions. | 4260 // Lose all the extensions. |
| 4213 for (size_t i = 0; i < m_extensions.size(); ++i) { | 4261 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 4214 ExtensionTracker* tracker = m_extensions[i]; | 4262 ExtensionTracker* tracker = m_extensions[i].get(); |
| 4215 tracker->loseExtension(); | 4263 tracker->loseExtension(); |
| 4216 } | 4264 } |
| 4217 | 4265 |
| 4218 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) | 4266 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) |
| 4219 m_extensionEnabled[i] = false; | 4267 m_extensionEnabled[i] = false; |
| 4220 | 4268 |
| 4221 removeAllCompressedTextureFormats(); | 4269 removeAllCompressedTextureFormats(); |
| 4222 | 4270 |
| 4223 if (mode != RealLostContext) | 4271 if (mode != RealLostContext) |
| 4224 destroyContext(); | 4272 destroyContext(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4283 | 4331 |
| 4284 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) | 4332 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) |
| 4285 { | 4333 { |
| 4286 ASSERT(!isContextLost()); | 4334 ASSERT(!isContextLost()); |
| 4287 m_contextObjects.add(object); | 4335 m_contextObjects.add(object); |
| 4288 } | 4336 } |
| 4289 | 4337 |
| 4290 void WebGLRenderingContextBase::detachAndRemoveAllObjects() | 4338 void WebGLRenderingContextBase::detachAndRemoveAllObjects() |
| 4291 { | 4339 { |
| 4292 while (m_contextObjects.size() > 0) { | 4340 while (m_contextObjects.size() > 0) { |
| 4293 HashSet<WebGLContextObject*>::iterator it = m_contextObjects.begin(); | 4341 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> >::iterator it = m_contextObjects.begin(); |
| 4294 (*it)->detachContext(); | 4342 (*it)->detachContext(); |
| 4295 } | 4343 } |
| 4296 } | 4344 } |
| 4297 | 4345 |
| 4298 bool WebGLRenderingContextBase::hasPendingActivity() const | 4346 bool WebGLRenderingContextBase::hasPendingActivity() const |
| 4299 { | 4347 { |
| 4300 return false; | 4348 return false; |
| 4301 } | 4349 } |
| 4302 | 4350 |
| 4303 void WebGLRenderingContextBase::stop() | 4351 void WebGLRenderingContextBase::stop() |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5467 if (!frame) | 5515 if (!frame) |
| 5468 return; | 5516 return; |
| 5469 | 5517 |
| 5470 Settings* settings = frame->settings(); | 5518 Settings* settings = frame->settings(); |
| 5471 | 5519 |
| 5472 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) | 5520 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) |
| 5473 return; | 5521 return; |
| 5474 | 5522 |
| 5475 // If the context was lost due to RealLostContext, we need to destroy the ol d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou gh. | 5523 // If the context was lost due to RealLostContext, we need to destroy the ol d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou gh. |
| 5476 if (m_drawingBuffer) { | 5524 if (m_drawingBuffer) { |
| 5525 #if ENABLE(OILPAN) | |
| 5526 if (m_sharedWebGraphicsContext3D) | |
| 5527 m_sharedWebGraphicsContext3D->reset(); | |
| 5528 #endif | |
| 5477 m_drawingBuffer->beginDestruction(); | 5529 m_drawingBuffer->beginDestruction(); |
| 5478 m_drawingBuffer.clear(); | 5530 m_drawingBuffer.clear(); |
|
haraken
2014/07/15 15:04:56
It's a pain that we have to manage both m_sharedWe
sof
2014/07/15 16:23:00
It's not that bad, is it? We access the m_shared*
sof
2014/07/15 21:49:07
Added drawingBuffer() accessor.
| |
| 5479 } | 5531 } |
| 5480 | 5532 |
| 5481 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings, version( )); | 5533 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings, version( )); |
| 5482 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0)); | 5534 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0)); |
| 5483 RefPtr<DrawingBuffer> drawingBuffer; | 5535 RefPtr<DrawingBuffer> drawingBuffer; |
| 5484 // Even if a non-null WebGraphicsContext3D is created, until it's made curre nt, it isn't known whether the context is still lost. | 5536 // Even if a non-null WebGraphicsContext3D is created, until it's made curre nt, it isn't known whether the context is still lost. |
| 5485 if (context) { | 5537 if (context) { |
| 5486 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 5538 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| 5487 drawingBuffer = createDrawingBuffer(context.release()); | 5539 drawingBuffer = createDrawingBuffer(context.release()); |
| 5488 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i s set to null. | 5540 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i s set to null. |
| 5489 } | 5541 } |
| 5490 if (!drawingBuffer) { | 5542 if (!drawingBuffer) { |
| 5491 if (m_contextLostMode == RealLostContext) { | 5543 if (m_contextLostMode == RealLostContext) { |
| 5492 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); | 5544 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); |
| 5493 } else { | 5545 } else { |
| 5494 // This likely shouldn't happen but is the best way to report it to the WebGL app. | 5546 // This likely shouldn't happen but is the best way to report it to the WebGL app. |
| 5495 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); | 5547 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); |
| 5496 } | 5548 } |
| 5497 return; | 5549 return; |
| 5498 } | 5550 } |
| 5499 | 5551 |
| 5500 m_drawingBuffer = drawingBuffer.release(); | 5552 m_drawingBuffer = drawingBuffer.release(); |
| 5553 #if ENABLE(OILPAN) | |
| 5554 if (m_sharedWebGraphicsContext3D) | |
| 5555 m_sharedWebGraphicsContext3D->update(m_drawingBuffer); | |
| 5556 else | |
| 5557 m_sharedWebGraphicsContext3D = WebGLSharedWebGraphicsContext3D::create(m _drawingBuffer); | |
| 5558 #endif | |
| 5559 | |
| 5501 m_drawingBuffer->bind(); | 5560 m_drawingBuffer->bind(); |
| 5502 m_lostContextErrors.clear(); | 5561 m_lostContextErrors.clear(); |
| 5503 m_contextLost = false; | 5562 m_contextLost = false; |
| 5504 | 5563 |
| 5505 setupFlags(); | 5564 setupFlags(); |
| 5506 initializeNewContext(); | 5565 initializeNewContext(); |
| 5507 markContextChanged(CanvasContextChanged); | 5566 markContextChanged(CanvasContextChanged); |
| 5508 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); | 5567 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); |
| 5509 } | 5568 } |
| 5510 | 5569 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5600 InspectorInstrumentation::didFireWebGLWarning(canvas()); | 5659 InspectorInstrumentation::didFireWebGLWarning(canvas()); |
| 5601 } | 5660 } |
| 5602 | 5661 |
| 5603 void WebGLRenderingContextBase::applyStencilTest() | 5662 void WebGLRenderingContextBase::applyStencilTest() |
| 5604 { | 5663 { |
| 5605 bool haveStencilBuffer = false; | 5664 bool haveStencilBuffer = false; |
| 5606 | 5665 |
| 5607 if (m_framebufferBinding) | 5666 if (m_framebufferBinding) |
| 5608 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); | 5667 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); |
| 5609 else { | 5668 else { |
| 5610 RefPtr<WebGLContextAttributes> attributes = getContextAttributes(); | 5669 RefPtrWillBeRawPtr<WebGLContextAttributes> attributes = getContextAttrib utes(); |
| 5611 haveStencilBuffer = attributes->stencil(); | 5670 haveStencilBuffer = attributes->stencil(); |
| 5612 } | 5671 } |
| 5613 enableOrDisable(GL_STENCIL_TEST, | 5672 enableOrDisable(GL_STENCIL_TEST, |
| 5614 m_stencilEnabled && haveStencilBuffer); | 5673 m_stencilEnabled && haveStencilBuffer); |
| 5615 } | 5674 } |
| 5616 | 5675 |
| 5617 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 5676 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) |
| 5618 { | 5677 { |
| 5619 if (isContextLost()) | 5678 if (isContextLost()) |
| 5620 return; | 5679 return; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5694 for (int i = startIndex; i >= 0; --i) { | 5753 for (int i = startIndex; i >= 0; --i) { |
| 5695 if (m_textureUnits[i].m_texture2DBinding | 5754 if (m_textureUnits[i].m_texture2DBinding |
| 5696 || m_textureUnits[i].m_textureCubeMapBinding) { | 5755 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5697 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5756 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5698 return; | 5757 return; |
| 5699 } | 5758 } |
| 5700 } | 5759 } |
| 5701 m_onePlusMaxNonDefaultTextureUnit = 0; | 5760 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5702 } | 5761 } |
| 5703 | 5762 |
| 5763 void WebGLRenderingContextBase::TextureUnitState::trace(Visitor* visitor) | |
| 5764 { | |
| 5765 visitor->trace(m_texture2DBinding); | |
| 5766 visitor->trace(m_textureCubeMapBinding); | |
| 5767 } | |
| 5768 | |
| 5769 void WebGLRenderingContextBase::trace(Visitor* visitor) | |
| 5770 { | |
| 5771 visitor->trace(m_contextObjects); | |
| 5772 visitor->trace(m_contextLostCallbackAdapter); | |
| 5773 visitor->trace(m_errorMessageCallbackAdapter); | |
| 5774 visitor->trace(m_boundArrayBuffer); | |
| 5775 visitor->trace(m_defaultVertexArrayObject); | |
| 5776 visitor->trace(m_boundVertexArrayObject); | |
| 5777 visitor->trace(m_vertexAttrib0Buffer); | |
| 5778 visitor->trace(m_currentProgram); | |
| 5779 visitor->trace(m_framebufferBinding); | |
| 5780 visitor->trace(m_renderbufferBinding); | |
| 5781 visitor->trace(m_textureUnits); | |
| 5782 visitor->trace(m_blackTexture2D); | |
| 5783 visitor->trace(m_blackTextureCubeMap); | |
| 5784 visitor->trace(m_requestedAttributes); | |
| 5785 visitor->trace(m_extensions); | |
| 5786 CanvasRenderingContext::trace(visitor); | |
| 5787 } | |
| 5788 | |
| 5789 #if ENABLE(OILPAN) | |
| 5790 PassRefPtr<WebGLSharedWebGraphicsContext3D> WebGLRenderingContextBase::sharedWeb GraphicsContext3D() | |
| 5791 { | |
| 5792 return m_sharedWebGraphicsContext3D; | |
| 5793 } | |
| 5794 #endif | |
| 5795 | |
| 5704 } // namespace WebCore | 5796 } // namespace WebCore |
| OLD | NEW |