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