| 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) | |
| 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) |
| 519 , m_contextLost(false) | 553 , m_contextLost(false) |
| 520 , m_contextLostMode(SyntheticLostContext) | 554 , m_contextLostMode(SyntheticLostContext) |
| 521 , m_requestedAttributes(requestedAttributes->clone()) | 555 , m_requestedAttributes(requestedAttributes->clone()) |
| 522 , m_synthesizedErrorsToConsole(true) | 556 , m_synthesizedErrorsToConsole(true) |
| 523 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 557 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
| 524 , m_multisamplingAllowed(false) | 558 , m_multisamplingAllowed(false) |
| 525 , m_multisamplingObserverRegistered(false) | 559 , m_multisamplingObserverRegistered(false) |
| 526 , m_onePlusMaxEnabledAttribIndex(0) | 560 , m_onePlusMaxEnabledAttribIndex(0) |
| 527 , m_onePlusMaxNonDefaultTextureUnit(0) | 561 , m_onePlusMaxNonDefaultTextureUnit(0) |
| 528 , m_savingImage(false) | 562 , m_savingImage(false) |
| 529 { | 563 { |
| 530 ASSERT(context); | 564 ASSERT(context); |
| 531 | 565 |
| 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 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); |
| 539 if (!m_drawingBuffer) | 573 if (!buffer) |
| 540 return; | 574 return; |
| 541 | 575 |
| 542 m_drawingBuffer->bind(); | 576 #if ENABLE(OILPAN) |
| 577 m_sharedWebGraphicsContext3D = WebGLSharedWebGraphicsContext3D::create(buffe
r.release()); |
| 578 #else |
| 579 m_drawingBuffer = buffer.release(); |
| 580 #endif |
| 581 |
| 582 drawingBuffer()->bind(); |
| 543 setupFlags(); | 583 setupFlags(); |
| 544 initializeNewContext(); | 584 initializeNewContext(); |
| 545 } | 585 } |
| 546 | 586 |
| 547 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn
Ptr<blink::WebGraphicsContext3D> context) | 587 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn
Ptr<blink::WebGraphicsContext3D> context) |
| 548 { | 588 { |
| 549 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 589 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); |
| 550 | 590 |
| 551 blink::WebGraphicsContext3D::Attributes attrs; | 591 blink::WebGraphicsContext3D::Attributes attrs; |
| 552 attrs.alpha = m_requestedAttributes->alpha(); | 592 attrs.alpha = m_requestedAttributes->alpha(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 addContextObject(m_defaultVertexArrayObject.get()); | 658 addContextObject(m_defaultVertexArrayObject.get()); |
| 619 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 659 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 620 | 660 |
| 621 m_vertexAttribValue.resize(m_maxVertexAttribs); | 661 m_vertexAttribValue.resize(m_maxVertexAttribs); |
| 622 | 662 |
| 623 createFallbackBlackTextures1x1(); | 663 createFallbackBlackTextures1x1(); |
| 624 | 664 |
| 625 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 665 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 626 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 666 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 627 | 667 |
| 628 m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallbac
k(this)); | 668 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi
s); |
| 629 m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessa
geCallback(this)); | 669 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c
reate(this); |
| 630 | 670 |
| 631 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 671 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
| 632 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 672 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
| 633 | 673 |
| 634 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. | 674 // 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(); | 675 webContext()->flush(); |
| 636 | 676 |
| 637 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 677 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
| 638 m_extensionEnabled[i] = false; | 678 m_extensionEnabled[i] = false; |
| 639 | 679 |
| 640 activateContext(this); | 680 activateContext(this); |
| 641 } | 681 } |
| 642 | 682 |
| 643 void WebGLRenderingContextBase::setupFlags() | 683 void WebGLRenderingContextBase::setupFlags() |
| 644 { | 684 { |
| 645 ASSERT(m_drawingBuffer); | 685 ASSERT(drawingBuffer()); |
| 646 if (Page* p = canvas()->document().page()) { | 686 if (Page* p = canvas()->document().page()) { |
| 647 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled
(); | 687 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled
(); |
| 648 | 688 |
| 649 if (!m_multisamplingObserverRegistered && m_requestedAttributes->antiali
as()) { | 689 if (!m_multisamplingObserverRegistered && m_requestedAttributes->antiali
as()) { |
| 650 m_multisamplingAllowed = m_drawingBuffer->multisample(); | 690 m_multisamplingAllowed = drawingBuffer()->multisample(); |
| 651 p->addMultisamplingChangedObserver(this); | 691 p->addMultisamplingChangedObserver(this); |
| 652 m_multisamplingObserverRegistered = true; | 692 m_multisamplingObserverRegistered = true; |
| 653 } | 693 } |
| 654 } | 694 } |
| 655 | 695 |
| 656 m_isGLES2NPOTStrict = !extensionsUtil()->isExtensionEnabled("GL_OES_texture_
npot"); | 696 m_isGLES2NPOTStrict = !extensionsUtil()->isExtensionEnabled("GL_OES_texture_
npot"); |
| 657 m_isDepthStencilSupported = extensionsUtil()->isExtensionEnabled("GL_OES_pac
ked_depth_stencil"); | 697 m_isDepthStencilSupported = extensionsUtil()->isExtensionEnabled("GL_OES_pac
ked_depth_stencil"); |
| 658 } | 698 } |
| 659 | 699 |
| 660 void WebGLRenderingContextBase::addCompressedTextureFormat(GLenum format) | 700 void WebGLRenderingContextBase::addCompressedTextureFormat(GLenum format) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 671 // Helper function for V8 bindings to identify what version of WebGL a CanvasRen
deringContext supports. | 711 // Helper function for V8 bindings to identify what version of WebGL a CanvasRen
deringContext supports. |
| 672 unsigned WebGLRenderingContextBase::getWebGLVersion(const CanvasRenderingContext
* context) | 712 unsigned WebGLRenderingContextBase::getWebGLVersion(const CanvasRenderingContext
* context) |
| 673 { | 713 { |
| 674 if (!context->is3d()) | 714 if (!context->is3d()) |
| 675 return 0; | 715 return 0; |
| 676 return static_cast<const WebGLRenderingContextBase*>(context)->version(); | 716 return static_cast<const WebGLRenderingContextBase*>(context)->version(); |
| 677 } | 717 } |
| 678 | 718 |
| 679 WebGLRenderingContextBase::~WebGLRenderingContextBase() | 719 WebGLRenderingContextBase::~WebGLRenderingContextBase() |
| 680 { | 720 { |
| 721 #if !ENABLE(OILPAN) |
| 681 // Remove all references to WebGLObjects so if they are the last reference | 722 // 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. | 723 // they will be freed before the last context is removed from the context gr
oup. |
| 683 m_boundArrayBuffer = nullptr; | 724 m_boundArrayBuffer = nullptr; |
| 684 m_defaultVertexArrayObject = nullptr; | 725 m_defaultVertexArrayObject = nullptr; |
| 685 m_boundVertexArrayObject = nullptr; | 726 m_boundVertexArrayObject = nullptr; |
| 686 m_vertexAttrib0Buffer = nullptr; | 727 m_vertexAttrib0Buffer = nullptr; |
| 687 m_currentProgram = nullptr; | 728 m_currentProgram = nullptr; |
| 688 m_framebufferBinding = nullptr; | 729 m_framebufferBinding = nullptr; |
| 689 m_renderbufferBinding = nullptr; | 730 m_renderbufferBinding = nullptr; |
| 690 | 731 |
| 691 for (size_t i = 0; i < m_textureUnits.size(); ++i) { | 732 for (size_t i = 0; i < m_textureUnits.size(); ++i) { |
| 692 m_textureUnits[i].m_texture2DBinding = nullptr; | 733 m_textureUnits[i].m_texture2DBinding = nullptr; |
| 693 m_textureUnits[i].m_textureCubeMapBinding = nullptr; | 734 m_textureUnits[i].m_textureCubeMapBinding = nullptr; |
| 694 } | 735 } |
| 695 | 736 |
| 696 m_blackTexture2D = nullptr; | 737 m_blackTexture2D = nullptr; |
| 697 m_blackTextureCubeMap = nullptr; | 738 m_blackTextureCubeMap = nullptr; |
| 698 | 739 |
| 699 detachAndRemoveAllObjects(); | 740 detachAndRemoveAllObjects(); |
| 700 | 741 |
| 701 // release all extensions | 742 // Release all extensions now. |
| 702 for (size_t i = 0; i < m_extensions.size(); ++i) | 743 m_extensions.clear(); |
| 703 delete m_extensions[i]; | 744 #endif |
| 704 | 745 |
| 705 // Context must be removed from the group prior to the destruction of the | 746 // Context must be removed from the group prior to the destruction of the |
| 706 // WebGraphicsContext3D, otherwise shared objects may not be properly delete
d. | 747 // WebGraphicsContext3D, otherwise shared objects may not be properly delete
d. |
| 707 m_contextGroup->removeContext(this); | 748 m_contextGroup->removeContext(this); |
| 708 | 749 |
| 709 destroyContext(); | 750 destroyContext(); |
| 710 | 751 |
| 711 #if !ENABLE(OILPAN) | 752 #if !ENABLE(OILPAN) |
| 712 if (m_multisamplingObserverRegistered) { | 753 if (m_multisamplingObserverRegistered) |
| 713 Page* page = canvas()->document().page(); | 754 if (Page* page = canvas()->document().page()) |
| 714 if (page) | |
| 715 page->removeMultisamplingChangedObserver(this); | 755 page->removeMultisamplingChangedObserver(this); |
| 716 } | |
| 717 #endif | 756 #endif |
| 718 | 757 |
| 719 willDestroyContext(this); | 758 willDestroyContext(this); |
| 720 } | 759 } |
| 721 | 760 |
| 722 void WebGLRenderingContextBase::destroyContext() | 761 void WebGLRenderingContextBase::destroyContext() |
| 723 { | 762 { |
| 724 m_contextLost = true; | 763 m_contextLost = true; |
| 725 | 764 |
| 726 if (!m_drawingBuffer) | 765 if (!drawingBuffer()) |
| 727 return; | 766 return; |
| 728 | 767 |
| 729 m_extensionsUtil.clear(); | 768 m_extensionsUtil.clear(); |
| 730 | 769 |
| 731 webContext()->setContextLostCallback(0); | 770 webContext()->setContextLostCallback(0); |
| 732 webContext()->setErrorMessageCallback(0); | 771 webContext()->setErrorMessageCallback(0); |
| 733 | 772 |
| 734 ASSERT(m_drawingBuffer); | 773 ASSERT(drawingBuffer()); |
| 774 #if ENABLE(OILPAN) |
| 775 // The DrawingBuffer ref pointers are cleared, but the |
| 776 // WebGLSharedWebGraphicsContext3D object will hold onto the |
| 777 // DrawingBuffer for as long as needed (== until all |
| 778 // context objects have been finalized), at which point |
| 779 // DrawingBuffer destruction happens. |
| 780 m_sharedWebGraphicsContext3D.clear(); |
| 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 drawingBuffer()->markContentsChanged(); |
| 745 | 793 |
| 746 m_layerCleared = false; | 794 m_layerCleared = false; |
| 747 RenderBox* renderBox = canvas()->renderBox(); | 795 RenderBox* renderBox = canvas()->renderBox(); |
| 748 if (renderBox && renderBox->hasAcceleratedCompositing()) { | 796 if (renderBox && renderBox->hasAcceleratedCompositing()) { |
| 749 m_markedCanvasDirty = true; | 797 m_markedCanvasDirty = true; |
| 750 canvas()->clearCopiedImage(); | 798 canvas()->clearCopiedImage(); |
| 751 renderBox->contentChanged(changeType); | 799 renderBox->contentChanged(changeType); |
| 752 } else { | 800 } else { |
| 753 if (!m_markedCanvasDirty) { | 801 if (!m_markedCanvasDirty) { |
| 754 m_markedCanvasDirty = true; | 802 m_markedCanvasDirty = true; |
| 755 canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); | 803 canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); |
| 756 } | 804 } |
| 757 } | 805 } |
| 758 } | 806 } |
| 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 (!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 10 matching lines...) Expand all Loading... |
| 790 } | 838 } |
| 791 if (contextAttributes->stencil()) { | 839 if (contextAttributes->stencil()) { |
| 792 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 840 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 793 webContext()->clearStencil(m_clearStencil & m_stencilMask); | 841 webContext()->clearStencil(m_clearStencil & m_stencilMask); |
| 794 else | 842 else |
| 795 webContext()->clearStencil(0); | 843 webContext()->clearStencil(0); |
| 796 clearMask |= GL_STENCIL_BUFFER_BIT; | 844 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 797 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 845 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 798 } | 846 } |
| 799 | 847 |
| 800 m_drawingBuffer->clearFramebuffers(clearMask); | 848 drawingBuffer()->clearFramebuffers(clearMask); |
| 801 | 849 |
| 802 restoreStateAfterClear(); | 850 restoreStateAfterClear(); |
| 803 if (m_framebufferBinding) | 851 if (m_framebufferBinding) |
| 804 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 852 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 805 m_layerCleared = true; | 853 m_layerCleared = true; |
| 806 | 854 |
| 807 return combinedClear; | 855 return combinedClear; |
| 808 } | 856 } |
| 809 | 857 |
| 810 void WebGLRenderingContextBase::restoreStateAfterClear() | 858 void WebGLRenderingContextBase::restoreStateAfterClear() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 821 m_colorMask[2], m_colorMask[3]); | 869 m_colorMask[2], m_colorMask[3]); |
| 822 webContext()->clearDepth(m_clearDepth); | 870 webContext()->clearDepth(m_clearDepth); |
| 823 webContext()->clearStencil(m_clearStencil); | 871 webContext()->clearStencil(m_clearStencil); |
| 824 webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); | 872 webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 825 webContext()->depthMask(m_depthMask); | 873 webContext()->depthMask(m_depthMask); |
| 826 } | 874 } |
| 827 | 875 |
| 828 void WebGLRenderingContextBase::markLayerComposited() | 876 void WebGLRenderingContextBase::markLayerComposited() |
| 829 { | 877 { |
| 830 if (!isContextLost()) | 878 if (!isContextLost()) |
| 831 m_drawingBuffer->markLayerComposited(); | 879 drawingBuffer()->markLayerComposited(); |
| 832 } | 880 } |
| 833 | 881 |
| 834 void WebGLRenderingContextBase::paintRenderingResultsToCanvas() | 882 void WebGLRenderingContextBase::paintRenderingResultsToCanvas() |
| 835 { | 883 { |
| 836 if (isContextLost()) { | 884 if (isContextLost()) { |
| 837 canvas()->clearPresentationCopy(); | 885 canvas()->clearPresentationCopy(); |
| 838 return; | 886 return; |
| 839 } | 887 } |
| 840 | 888 |
| 841 if (canvas()->document().printing()) | 889 if (canvas()->document().printing()) |
| 842 canvas()->clearPresentationCopy(); | 890 canvas()->clearPresentationCopy(); |
| 843 | 891 |
| 844 // Until the canvas is written to by the application, the clear that | 892 // Until the canvas is written to by the application, the clear that |
| 845 // happened after it was composited should be ignored by the compositor. | 893 // happened after it was composited should be ignored by the compositor. |
| 846 if (m_drawingBuffer->layerComposited() && !m_requestedAttributes->preserveDr
awingBuffer()) { | 894 if (drawingBuffer()->layerComposited() && !m_requestedAttributes->preserveDr
awingBuffer()) { |
| 847 m_drawingBuffer->paintCompositedResultsToCanvas(canvas()->buffer()); | 895 drawingBuffer()->paintCompositedResultsToCanvas(canvas()->buffer()); |
| 848 | 896 |
| 849 canvas()->makePresentationCopy(); | 897 canvas()->makePresentationCopy(); |
| 850 } else | 898 } else |
| 851 canvas()->clearPresentationCopy(); | 899 canvas()->clearPresentationCopy(); |
| 852 | 900 |
| 853 clearIfComposited(); | 901 clearIfComposited(); |
| 854 | 902 |
| 855 if (!m_markedCanvasDirty && !m_layerCleared) | 903 if (!m_markedCanvasDirty && !m_layerCleared) |
| 856 return; | 904 return; |
| 857 | 905 |
| 858 canvas()->clearCopiedImage(); | 906 canvas()->clearCopiedImage(); |
| 859 m_markedCanvasDirty = false; | 907 m_markedCanvasDirty = false; |
| 860 | 908 |
| 861 ScopedTexture2DRestorer restorer(this); | 909 ScopedTexture2DRestorer restorer(this); |
| 862 | 910 |
| 863 m_drawingBuffer->commit(); | 911 drawingBuffer()->commit(); |
| 864 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu
ffer.get(), m_savingImage)) { | 912 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(drawingBuff
er(), m_savingImage)) { |
| 865 canvas()->ensureUnacceleratedImageBuffer(); | 913 canvas()->ensureUnacceleratedImageBuffer(); |
| 866 if (canvas()->hasImageBuffer()) | 914 if (canvas()->hasImageBuffer()) |
| 867 m_drawingBuffer->paintRenderingResultsToCanvas(canvas()->buffer()); | 915 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); |
| 868 } | 916 } |
| 869 | 917 |
| 870 if (m_framebufferBinding) | 918 if (m_framebufferBinding) |
| 871 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 919 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 872 else | 920 else |
| 873 m_drawingBuffer->bind(); | 921 drawingBuffer()->bind(); |
| 874 } | 922 } |
| 875 | 923 |
| 876 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul
tsToImageData() | 924 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul
tsToImageData() |
| 877 { | 925 { |
| 878 if (isContextLost()) | 926 if (isContextLost()) |
| 879 return nullptr; | 927 return nullptr; |
| 880 | 928 |
| 881 clearIfComposited(); | 929 clearIfComposited(); |
| 882 m_drawingBuffer->commit(); | 930 drawingBuffer()->commit(); |
| 883 int width, height; | 931 int width, height; |
| 884 RefPtr<Uint8ClampedArray> imageDataPixels = m_drawingBuffer->paintRenderingR
esultsToImageData(width, height); | 932 RefPtr<Uint8ClampedArray> imageDataPixels = drawingBuffer()->paintRenderingR
esultsToImageData(width, height); |
| 885 if (!imageDataPixels) | 933 if (!imageDataPixels) |
| 886 return nullptr; | 934 return nullptr; |
| 887 | 935 |
| 888 if (m_framebufferBinding) | 936 if (m_framebufferBinding) |
| 889 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 937 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 890 else | 938 else |
| 891 m_drawingBuffer->bind(); | 939 drawingBuffer()->bind(); |
| 892 | 940 |
| 893 return ImageData::create(IntSize(width, height), imageDataPixels); | 941 return ImageData::create(IntSize(width, height), imageDataPixels); |
| 894 } | 942 } |
| 895 | 943 |
| 896 void WebGLRenderingContextBase::reshape(int width, int height) | 944 void WebGLRenderingContextBase::reshape(int width, int height) |
| 897 { | 945 { |
| 898 if (isContextLost()) | 946 if (isContextLost()) |
| 899 return; | 947 return; |
| 900 | 948 |
| 901 // This is an approximation because at WebGLRenderingContextBase level we do
n't | 949 // This is an approximation because at WebGLRenderingContextBase level we do
n't |
| 902 // know if the underlying FBO uses textures or renderbuffers. | 950 // know if the underlying FBO uses textures or renderbuffers. |
| 903 GLint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); | 951 GLint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); |
| 904 // Limit drawing buffer size to 4k to avoid memory exhaustion. | 952 // Limit drawing buffer size to 4k to avoid memory exhaustion. |
| 905 const int sizeUpperLimit = 4096; | 953 const int sizeUpperLimit = 4096; |
| 906 maxSize = std::min(maxSize, sizeUpperLimit); | 954 maxSize = std::min(maxSize, sizeUpperLimit); |
| 907 GLint maxWidth = std::min(maxSize, m_maxViewportDims[0]); | 955 GLint maxWidth = std::min(maxSize, m_maxViewportDims[0]); |
| 908 GLint maxHeight = std::min(maxSize, m_maxViewportDims[1]); | 956 GLint maxHeight = std::min(maxSize, m_maxViewportDims[1]); |
| 909 width = clamp(width, 1, maxWidth); | 957 width = clamp(width, 1, maxWidth); |
| 910 height = clamp(height, 1, maxHeight); | 958 height = clamp(height, 1, maxHeight); |
| 911 | 959 |
| 912 if (m_needsUpdate) { | 960 if (m_needsUpdate) { |
| 913 RenderBox* renderBox = canvas()->renderBox(); | 961 RenderBox* renderBox = canvas()->renderBox(); |
| 914 if (renderBox && renderBox->hasAcceleratedCompositing()) | 962 if (renderBox && renderBox->hasAcceleratedCompositing()) |
| 915 renderBox->contentChanged(CanvasChanged); | 963 renderBox->contentChanged(CanvasChanged); |
| 916 m_needsUpdate = false; | 964 m_needsUpdate = false; |
| 917 } | 965 } |
| 918 | 966 |
| 919 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off | 967 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off |
| 920 // clear (and this matches what reshape will do). | 968 // clear (and this matches what reshape will do). |
| 921 m_drawingBuffer->reset(IntSize(width, height)); | 969 drawingBuffer()->reset(IntSize(width, height)); |
| 922 restoreStateAfterClear(); | 970 restoreStateAfterClear(); |
| 923 | 971 |
| 924 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ
eTextureUnit].m_texture2DBinding.get())); | 972 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ
eTextureUnit].m_texture2DBinding.get())); |
| 925 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB
inding.get())); | 973 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB
inding.get())); |
| 926 if (m_framebufferBinding) | 974 if (m_framebufferBinding) |
| 927 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 975 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 928 } | 976 } |
| 929 | 977 |
| 930 int WebGLRenderingContextBase::drawingBufferWidth() const | 978 int WebGLRenderingContextBase::drawingBufferWidth() const |
| 931 { | 979 { |
| 932 return isContextLost() ? 0 : m_drawingBuffer->size().width(); | 980 return isContextLost() ? 0 : drawingBuffer()->size().width(); |
| 933 } | 981 } |
| 934 | 982 |
| 935 int WebGLRenderingContextBase::drawingBufferHeight() const | 983 int WebGLRenderingContextBase::drawingBufferHeight() const |
| 936 { | 984 { |
| 937 return isContextLost() ? 0 : m_drawingBuffer->size().height(); | 985 return isContextLost() ? 0 : drawingBuffer()->size().height(); |
| 938 } | 986 } |
| 939 | 987 |
| 940 unsigned WebGLRenderingContextBase::sizeInBytes(GLenum type) | 988 unsigned WebGLRenderingContextBase::sizeInBytes(GLenum type) |
| 941 { | 989 { |
| 942 switch (type) { | 990 switch (type) { |
| 943 case GL_BYTE: | 991 case GL_BYTE: |
| 944 return sizeof(GLbyte); | 992 return sizeof(GLbyte); |
| 945 case GL_UNSIGNED_BYTE: | 993 case GL_UNSIGNED_BYTE: |
| 946 return sizeof(GLubyte); | 994 return sizeof(GLubyte); |
| 947 case GL_SHORT: | 995 case GL_SHORT: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 963 { | 1011 { |
| 964 if (isContextLost()) | 1012 if (isContextLost()) |
| 965 return; | 1013 return; |
| 966 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { | 1014 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { |
| 967 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); | 1015 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); |
| 968 return; | 1016 return; |
| 969 } | 1017 } |
| 970 m_activeTextureUnit = texture - GL_TEXTURE0; | 1018 m_activeTextureUnit = texture - GL_TEXTURE0; |
| 971 webContext()->activeTexture(texture); | 1019 webContext()->activeTexture(texture); |
| 972 | 1020 |
| 973 m_drawingBuffer->setActiveTextureUnit(texture); | 1021 drawingBuffer()->setActiveTextureUnit(texture); |
| 974 | 1022 |
| 975 } | 1023 } |
| 976 | 1024 |
| 977 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader*
shader) | 1025 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader*
shader) |
| 978 { | 1026 { |
| 979 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) | 1027 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) |
| 980 return; | 1028 return; |
| 981 if (!program->attachShader(shader)) { | 1029 if (!program->attachShader(shader)) { |
| 982 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); | 1030 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); |
| 983 return; | 1031 return; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 bool deleted; | 1098 bool deleted; |
| 1051 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1099 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1052 return; | 1100 return; |
| 1053 if (deleted) | 1101 if (deleted) |
| 1054 buffer = 0; | 1102 buffer = 0; |
| 1055 if (target != GL_FRAMEBUFFER) { | 1103 if (target != GL_FRAMEBUFFER) { |
| 1056 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1104 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
| 1057 return; | 1105 return; |
| 1058 } | 1106 } |
| 1059 m_framebufferBinding = buffer; | 1107 m_framebufferBinding = buffer; |
| 1060 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); | 1108 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); |
| 1061 if (!m_framebufferBinding) { | 1109 if (!m_framebufferBinding) { |
| 1062 // Instead of binding fb 0, bind the drawing buffer. | 1110 // Instead of binding fb 0, bind the drawing buffer. |
| 1063 m_drawingBuffer->bind(); | 1111 drawingBuffer()->bind(); |
| 1064 } else { | 1112 } else { |
| 1065 webContext()->bindFramebuffer(target, objectOrZero(buffer)); | 1113 webContext()->bindFramebuffer(target, objectOrZero(buffer)); |
| 1066 } | 1114 } |
| 1067 if (buffer) | 1115 if (buffer) |
| 1068 buffer->setHasEverBeenBound(); | 1116 buffer->setHasEverBeenBound(); |
| 1069 applyStencilTest(); | 1117 applyStencilTest(); |
| 1070 } | 1118 } |
| 1071 | 1119 |
| 1072 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe
r* renderBuffer) | 1120 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe
r* renderBuffer) |
| 1073 { | 1121 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1096 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1144 if (texture && texture->getTarget() && texture->getTarget() != target) { |
| 1097 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not
be used with multiple targets"); | 1145 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not
be used with multiple targets"); |
| 1098 return; | 1146 return; |
| 1099 } | 1147 } |
| 1100 GLint maxLevel = 0; | 1148 GLint maxLevel = 0; |
| 1101 if (target == GL_TEXTURE_2D) { | 1149 if (target == GL_TEXTURE_2D) { |
| 1102 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1150 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
| 1103 maxLevel = m_maxTextureLevel; | 1151 maxLevel = m_maxTextureLevel; |
| 1104 | 1152 |
| 1105 if (!m_activeTextureUnit) | 1153 if (!m_activeTextureUnit) |
| 1106 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); | 1154 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); |
| 1107 | 1155 |
| 1108 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1156 } else if (target == GL_TEXTURE_CUBE_MAP) { |
| 1109 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1157 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
| 1110 maxLevel = m_maxCubeMapTextureLevel; | 1158 maxLevel = m_maxCubeMapTextureLevel; |
| 1111 } else { | 1159 } else { |
| 1112 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1160 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
| 1113 return; | 1161 return; |
| 1114 } | 1162 } |
| 1115 | 1163 |
| 1116 webContext()->bindTexture(target, objectOrZero(texture)); | 1164 webContext()->bindTexture(target, objectOrZero(texture)); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1487 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
| 1440 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); | 1488 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); |
| 1441 return; | 1489 return; |
| 1442 } | 1490 } |
| 1443 const char* reason = "framebuffer incomplete"; | 1491 const char* reason = "framebuffer incomplete"; |
| 1444 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 1492 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 1445 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); | 1493 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); |
| 1446 return; | 1494 return; |
| 1447 } | 1495 } |
| 1448 clearIfComposited(); | 1496 clearIfComposited(); |
| 1449 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1497 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get()
); |
| 1450 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei
ght, border); | 1498 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei
ght, border); |
| 1451 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. | 1499 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. |
| 1452 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); | 1500 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); |
| 1453 } | 1501 } |
| 1454 | 1502 |
| 1455 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) | 1503 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 1456 { | 1504 { |
| 1457 if (isContextLost()) | 1505 if (isContextLost()) |
| 1458 return; | 1506 return; |
| 1459 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1507 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1482 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1530 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1483 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); | 1531 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); |
| 1484 return; | 1532 return; |
| 1485 } | 1533 } |
| 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(drawingBuffer(), 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 30 matching lines...) Expand all Loading... |
| 1605 | 1653 |
| 1606 m_boundVertexArrayObject->unbindBuffer(buffer); | 1654 m_boundVertexArrayObject->unbindBuffer(buffer); |
| 1607 } | 1655 } |
| 1608 | 1656 |
| 1609 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) | 1657 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
| 1610 { | 1658 { |
| 1611 if (!deleteObject(framebuffer)) | 1659 if (!deleteObject(framebuffer)) |
| 1612 return; | 1660 return; |
| 1613 if (framebuffer == m_framebufferBinding) { | 1661 if (framebuffer == m_framebufferBinding) { |
| 1614 m_framebufferBinding = nullptr; | 1662 m_framebufferBinding = nullptr; |
| 1615 m_drawingBuffer->setFramebufferBinding(0); | 1663 drawingBuffer()->setFramebufferBinding(0); |
| 1616 // Have to call bindFramebuffer here to bind back to internal fbo. | 1664 // Have to call bindFramebuffer here to bind back to internal fbo. |
| 1617 m_drawingBuffer->bind(); | 1665 drawingBuffer()->bind(); |
| 1618 } | 1666 } |
| 1619 } | 1667 } |
| 1620 | 1668 |
| 1621 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) | 1669 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) |
| 1622 { | 1670 { |
| 1623 deleteObject(program); | 1671 deleteObject(program); |
| 1624 // We don't reset m_currentProgram to 0 here because the deletion of the | 1672 // We don't reset m_currentProgram to 0 here because the deletion of the |
| 1625 // current program is delayed. | 1673 // current program is delayed. |
| 1626 } | 1674 } |
| 1627 | 1675 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1644 { | 1692 { |
| 1645 if (!deleteObject(texture)) | 1693 if (!deleteObject(texture)) |
| 1646 return; | 1694 return; |
| 1647 | 1695 |
| 1648 int maxBoundTextureIndex = -1; | 1696 int maxBoundTextureIndex = -1; |
| 1649 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { | 1697 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { |
| 1650 if (texture == m_textureUnits[i].m_texture2DBinding) { | 1698 if (texture == m_textureUnits[i].m_texture2DBinding) { |
| 1651 m_textureUnits[i].m_texture2DBinding = nullptr; | 1699 m_textureUnits[i].m_texture2DBinding = nullptr; |
| 1652 maxBoundTextureIndex = i; | 1700 maxBoundTextureIndex = i; |
| 1653 if (!i) | 1701 if (!i) |
| 1654 m_drawingBuffer->setTexture2DBinding(0); | 1702 drawingBuffer()->setTexture2DBinding(0); |
| 1655 } | 1703 } |
| 1656 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { | 1704 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { |
| 1657 m_textureUnits[i].m_textureCubeMapBinding = nullptr; | 1705 m_textureUnits[i].m_textureCubeMapBinding = nullptr; |
| 1658 maxBoundTextureIndex = i; | 1706 maxBoundTextureIndex = i; |
| 1659 } | 1707 } |
| 1660 } | 1708 } |
| 1661 if (m_framebufferBinding) | 1709 if (m_framebufferBinding) |
| 1662 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); | 1710 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); |
| 1663 | 1711 |
| 1664 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index | 1712 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 { | 1759 { |
| 1712 if (isContextLost() || !validateCapability("disable", cap)) | 1760 if (isContextLost() || !validateCapability("disable", cap)) |
| 1713 return; | 1761 return; |
| 1714 if (cap == GL_STENCIL_TEST) { | 1762 if (cap == GL_STENCIL_TEST) { |
| 1715 m_stencilEnabled = false; | 1763 m_stencilEnabled = false; |
| 1716 applyStencilTest(); | 1764 applyStencilTest(); |
| 1717 return; | 1765 return; |
| 1718 } | 1766 } |
| 1719 if (cap == GL_SCISSOR_TEST) { | 1767 if (cap == GL_SCISSOR_TEST) { |
| 1720 m_scissorEnabled = false; | 1768 m_scissorEnabled = false; |
| 1721 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1769 drawingBuffer()->setScissorEnabled(m_scissorEnabled); |
| 1722 } | 1770 } |
| 1723 webContext()->disable(cap); | 1771 webContext()->disable(cap); |
| 1724 } | 1772 } |
| 1725 | 1773 |
| 1726 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) | 1774 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) |
| 1727 { | 1775 { |
| 1728 if (isContextLost()) | 1776 if (isContextLost()) |
| 1729 return; | 1777 return; |
| 1730 if (index >= m_maxVertexAttribs) { | 1778 if (index >= m_maxVertexAttribs) { |
| 1731 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); | 1779 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 { | 1886 { |
| 1839 if (isContextLost() || !validateCapability("enable", cap)) | 1887 if (isContextLost() || !validateCapability("enable", cap)) |
| 1840 return; | 1888 return; |
| 1841 if (cap == GL_STENCIL_TEST) { | 1889 if (cap == GL_STENCIL_TEST) { |
| 1842 m_stencilEnabled = true; | 1890 m_stencilEnabled = true; |
| 1843 applyStencilTest(); | 1891 applyStencilTest(); |
| 1844 return; | 1892 return; |
| 1845 } | 1893 } |
| 1846 if (cap == GL_SCISSOR_TEST) { | 1894 if (cap == GL_SCISSOR_TEST) { |
| 1847 m_scissorEnabled = true; | 1895 m_scissorEnabled = true; |
| 1848 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1896 drawingBuffer()->setScissorEnabled(m_scissorEnabled); |
| 1849 } | 1897 } |
| 1850 webContext()->enable(cap); | 1898 webContext()->enable(cap); |
| 1851 } | 1899 } |
| 1852 | 1900 |
| 1853 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) | 1901 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) |
| 1854 { | 1902 { |
| 1855 if (isContextLost()) | 1903 if (isContextLost()) |
| 1856 return; | 1904 return; |
| 1857 if (index >= m_maxVertexAttribs) { | 1905 if (index >= m_maxVertexAttribs) { |
| 1858 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); | 1906 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); |
| (...skipping 141 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 = 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(drawingBuffer()->multisample()); |
| 2101 return attributes.release(); | 2149 return attributes.release(); |
| 2102 } | 2150 } |
| 2103 | 2151 |
| 2104 GLenum WebGLRenderingContextBase::getError() | 2152 GLenum WebGLRenderingContextBase::getError() |
| 2105 { | 2153 { |
| 2106 if (m_lostContextErrors.size()) { | 2154 if (m_lostContextErrors.size()) { |
| 2107 GLenum err = m_lostContextErrors.first(); | 2155 GLenum err = m_lostContextErrors.first(); |
| 2108 m_lostContextErrors.remove(0); | 2156 m_lostContextErrors.remove(0); |
| 2109 return err; | 2157 return err; |
| 2110 } | 2158 } |
| (...skipping 25 matching lines...) Expand all 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2993 } else { | 3041 } else { |
| 2994 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for UNPACK_COLORSPACE_CONVERSION_WEBGL"); | 3042 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for UNPACK_COLORSPACE_CONVERSION_WEBGL"); |
| 2995 return; | 3043 return; |
| 2996 } | 3044 } |
| 2997 break; | 3045 break; |
| 2998 case GL_PACK_ALIGNMENT: | 3046 case GL_PACK_ALIGNMENT: |
| 2999 case GL_UNPACK_ALIGNMENT: | 3047 case GL_UNPACK_ALIGNMENT: |
| 3000 if (param == 1 || param == 2 || param == 4 || param == 8) { | 3048 if (param == 1 || param == 2 || param == 4 || param == 8) { |
| 3001 if (pname == GL_PACK_ALIGNMENT) { | 3049 if (pname == GL_PACK_ALIGNMENT) { |
| 3002 m_packAlignment = param; | 3050 m_packAlignment = param; |
| 3003 m_drawingBuffer->setPackAlignment(param); | 3051 drawingBuffer()->setPackAlignment(param); |
| 3004 } else { // GL_UNPACK_ALIGNMENT: | 3052 } else { // GL_UNPACK_ALIGNMENT: |
| 3005 m_unpackAlignment = param; | 3053 m_unpackAlignment = param; |
| 3006 } | 3054 } |
| 3007 webContext()->pixelStorei(pname, param); | 3055 webContext()->pixelStorei(pname, param); |
| 3008 } else { | 3056 } else { |
| 3009 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); | 3057 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); |
| 3010 return; | 3058 return; |
| 3011 } | 3059 } |
| 3012 break; | 3060 break; |
| 3013 default: | 3061 default: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 } | 3144 } |
| 3097 if (pixels->byteLength() < totalBytesRequired) { | 3145 if (pixels->byteLength() < totalBytesRequired) { |
| 3098 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); | 3146 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); |
| 3099 return; | 3147 return; |
| 3100 } | 3148 } |
| 3101 | 3149 |
| 3102 clearIfComposited(); | 3150 clearIfComposited(); |
| 3103 void* data = pixels->baseAddress(); | 3151 void* data = pixels->baseAddress(); |
| 3104 | 3152 |
| 3105 { | 3153 { |
| 3106 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin
ding.get()); | 3154 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.g
et()); |
| 3107 webContext()->readPixels(x, y, width, height, format, type, data); | 3155 webContext()->readPixels(x, y, width, height, format, type, data); |
| 3108 } | 3156 } |
| 3109 | 3157 |
| 3110 #if OS(MACOSX) | 3158 #if OS(MACOSX) |
| 3111 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., | 3159 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., |
| 3112 // when alpha is off, readPixels should set alpha to 255 instead of 0. | 3160 // when alpha is off, readPixels should set alpha to 255 instead of 0. |
| 3113 if (!m_framebufferBinding && !m_drawingBuffer->getActualAttributes().alpha)
{ | 3161 if (!m_framebufferBinding && !drawingBuffer()->getActualAttributes().alpha)
{ |
| 3114 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); | 3162 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); |
| 3115 for (GLsizei iy = 0; iy < height; ++iy) { | 3163 for (GLsizei iy = 0; iy < height; ++iy) { |
| 3116 for (GLsizei ix = 0; ix < width; ++ix) { | 3164 for (GLsizei ix = 0; ix < width; ++ix) { |
| 3117 pixels[3] = 255; | 3165 pixels[3] = 255; |
| 3118 pixels += 4; | 3166 pixels += 4; |
| 3119 } | 3167 } |
| 3120 pixels += padding; | 3168 pixels += padding; |
| 3121 } | 3169 } |
| 3122 } | 3170 } |
| 3123 #endif | 3171 #endif |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3494 if (!canvas->is3D()) { | 3542 if (!canvas->is3D()) { |
| 3495 ImageBuffer* buffer = canvas->buffer(); | 3543 ImageBuffer* buffer = canvas->buffer(); |
| 3496 if (buffer && buffer->copyToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, | 3544 if (buffer && buffer->copyToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, |
| 3497 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3545 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3498 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3546 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
| 3499 return; | 3547 return; |
| 3500 } | 3548 } |
| 3501 } else { | 3549 } else { |
| 3502 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->
renderingContext()); | 3550 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->
renderingContext()); |
| 3503 ScopedTexture2DRestorer restorer(gl); | 3551 ScopedTexture2DRestorer restorer(gl); |
| 3504 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(webContext(), t
exture->object(), internalformat, type, | 3552 if (gl && gl->drawingBuffer()->copyToPlatformTexture(webContext(), t
exture->object(), internalformat, type, |
| 3505 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3553 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3506 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3554 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
| 3507 return; | 3555 return; |
| 3508 } | 3556 } |
| 3509 } | 3557 } |
| 3510 } | 3558 } |
| 3511 | 3559 |
| 3512 RefPtrWillBeRawPtr<ImageData> imageData = canvas->getImageData(); | 3560 RefPtrWillBeRawPtr<ImageData> imageData = canvas->getImageData(); |
| 3513 if (imageData) | 3561 if (imageData) |
| 3514 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); | 3562 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4197 m_contextLostMode = mode; | 4245 m_contextLostMode = mode; |
| 4198 | 4246 |
| 4199 if (mode == RealLostContext) { | 4247 if (mode == RealLostContext) { |
| 4200 // Inform the embedder that a lost context was received. In response, th
e embedder might | 4248 // Inform the embedder that a lost context was received. In response, th
e embedder might |
| 4201 // decide to take action such as asking the user for permission to use W
ebGL again. | 4249 // decide to take action such as asking the user for permission to use W
ebGL again. |
| 4202 if (LocalFrame* frame = canvas()->document().frame()) | 4250 if (LocalFrame* frame = canvas()->document().frame()) |
| 4203 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph
icsResetStatusARB()); | 4251 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph
icsResetStatusARB()); |
| 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 drawingBuffer()->setTexture2DBinding(0); |
| 4208 m_drawingBuffer->setFramebufferBinding(0); | 4256 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 22 matching lines...) Expand all Loading... |
| 4247 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); | 4295 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); |
| 4248 return; | 4296 return; |
| 4249 } | 4297 } |
| 4250 | 4298 |
| 4251 if (!m_restoreTimer.isActive()) | 4299 if (!m_restoreTimer.isActive()) |
| 4252 m_restoreTimer.startOneShot(0, FROM_HERE); | 4300 m_restoreTimer.startOneShot(0, FROM_HERE); |
| 4253 } | 4301 } |
| 4254 | 4302 |
| 4255 blink::WebLayer* WebGLRenderingContextBase::platformLayer() const | 4303 blink::WebLayer* WebGLRenderingContextBase::platformLayer() const |
| 4256 { | 4304 { |
| 4257 return isContextLost() ? 0 : m_drawingBuffer->platformLayer(); | 4305 return isContextLost() ? 0 : drawingBuffer()->platformLayer(); |
| 4258 } | 4306 } |
| 4259 | 4307 |
| 4260 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() | 4308 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() |
| 4261 { | 4309 { |
| 4262 ASSERT(!isContextLost()); | 4310 ASSERT(!isContextLost()); |
| 4263 if (!m_extensionsUtil) | 4311 if (!m_extensionsUtil) |
| 4264 m_extensionsUtil = Extensions3DUtil::create(webContext()); | 4312 m_extensionsUtil = Extensions3DUtil::create(webContext()); |
| 4265 return m_extensionsUtil.get(); | 4313 return m_extensionsUtil.get(); |
| 4266 } | 4314 } |
| 4267 | 4315 |
| (...skipping 15 matching lines...) Expand all 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 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5466 LocalFrame* frame = canvas()->document().frame(); | 5514 LocalFrame* frame = canvas()->document().frame(); |
| 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 (drawingBuffer()) { |
| 5525 #if ENABLE(OILPAN) |
| 5526 m_sharedWebGraphicsContext3D->dispose(); |
| 5527 #else |
| 5477 m_drawingBuffer->beginDestruction(); | 5528 m_drawingBuffer->beginDestruction(); |
| 5478 m_drawingBuffer.clear(); | 5529 m_drawingBuffer.clear(); |
| 5530 #endif |
| 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> buffer; |
| 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 buffer = 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 (!buffer) { |
| 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 #if ENABLE(OILPAN) |
| 5501 m_drawingBuffer->bind(); | 5553 if (m_sharedWebGraphicsContext3D) |
| 5554 m_sharedWebGraphicsContext3D->update(buffer.release()); |
| 5555 else |
| 5556 m_sharedWebGraphicsContext3D = WebGLSharedWebGraphicsContext3D::create(b
uffer.release()); |
| 5557 #else |
| 5558 m_drawingBuffer = buffer.release(); |
| 5559 #endif |
| 5560 |
| 5561 drawingBuffer()->bind(); |
| 5502 m_lostContextErrors.clear(); | 5562 m_lostContextErrors.clear(); |
| 5503 m_contextLost = false; | 5563 m_contextLost = false; |
| 5504 | 5564 |
| 5505 setupFlags(); | 5565 setupFlags(); |
| 5506 initializeNewContext(); | 5566 initializeNewContext(); |
| 5507 markContextChanged(CanvasContextChanged); | 5567 markContextChanged(CanvasContextChanged); |
| 5508 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte
xtrestored, false, true, "")); | 5568 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte
xtrestored, false, true, "")); |
| 5509 } | 5569 } |
| 5510 | 5570 |
| 5511 String WebGLRenderingContextBase::ensureNotNull(const String& text) const | 5571 String WebGLRenderingContextBase::ensureNotNull(const String& text) const |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5600 InspectorInstrumentation::didFireWebGLWarning(canvas()); | 5660 InspectorInstrumentation::didFireWebGLWarning(canvas()); |
| 5601 } | 5661 } |
| 5602 | 5662 |
| 5603 void WebGLRenderingContextBase::applyStencilTest() | 5663 void WebGLRenderingContextBase::applyStencilTest() |
| 5604 { | 5664 { |
| 5605 bool haveStencilBuffer = false; | 5665 bool haveStencilBuffer = false; |
| 5606 | 5666 |
| 5607 if (m_framebufferBinding) | 5667 if (m_framebufferBinding) |
| 5608 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); | 5668 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); |
| 5609 else { | 5669 else { |
| 5610 RefPtr<WebGLContextAttributes> attributes = getContextAttributes(); | 5670 RefPtrWillBeRawPtr<WebGLContextAttributes> attributes = getContextAttrib
utes(); |
| 5611 haveStencilBuffer = attributes->stencil(); | 5671 haveStencilBuffer = attributes->stencil(); |
| 5612 } | 5672 } |
| 5613 enableOrDisable(GL_STENCIL_TEST, | 5673 enableOrDisable(GL_STENCIL_TEST, |
| 5614 m_stencilEnabled && haveStencilBuffer); | 5674 m_stencilEnabled && haveStencilBuffer); |
| 5615 } | 5675 } |
| 5616 | 5676 |
| 5617 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 5677 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) |
| 5618 { | 5678 { |
| 5619 if (isContextLost()) | 5679 if (isContextLost()) |
| 5620 return; | 5680 return; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5694 for (int i = startIndex; i >= 0; --i) { | 5754 for (int i = startIndex; i >= 0; --i) { |
| 5695 if (m_textureUnits[i].m_texture2DBinding | 5755 if (m_textureUnits[i].m_texture2DBinding |
| 5696 || m_textureUnits[i].m_textureCubeMapBinding) { | 5756 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5697 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5757 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5698 return; | 5758 return; |
| 5699 } | 5759 } |
| 5700 } | 5760 } |
| 5701 m_onePlusMaxNonDefaultTextureUnit = 0; | 5761 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5702 } | 5762 } |
| 5703 | 5763 |
| 5764 void WebGLRenderingContextBase::TextureUnitState::trace(Visitor* visitor) |
| 5765 { |
| 5766 visitor->trace(m_texture2DBinding); |
| 5767 visitor->trace(m_textureCubeMapBinding); |
| 5768 } |
| 5769 |
| 5770 void WebGLRenderingContextBase::trace(Visitor* visitor) |
| 5771 { |
| 5772 visitor->trace(m_contextObjects); |
| 5773 visitor->trace(m_contextLostCallbackAdapter); |
| 5774 visitor->trace(m_errorMessageCallbackAdapter); |
| 5775 visitor->trace(m_boundArrayBuffer); |
| 5776 visitor->trace(m_defaultVertexArrayObject); |
| 5777 visitor->trace(m_boundVertexArrayObject); |
| 5778 visitor->trace(m_vertexAttrib0Buffer); |
| 5779 visitor->trace(m_currentProgram); |
| 5780 visitor->trace(m_framebufferBinding); |
| 5781 visitor->trace(m_renderbufferBinding); |
| 5782 visitor->trace(m_textureUnits); |
| 5783 visitor->trace(m_blackTexture2D); |
| 5784 visitor->trace(m_blackTextureCubeMap); |
| 5785 visitor->trace(m_requestedAttributes); |
| 5786 visitor->trace(m_extensions); |
| 5787 CanvasRenderingContext::trace(visitor); |
| 5788 } |
| 5789 |
| 5790 #if ENABLE(OILPAN) |
| 5791 PassRefPtr<WebGLSharedWebGraphicsContext3D> WebGLRenderingContextBase::sharedWeb
GraphicsContext3D() const |
| 5792 { |
| 5793 return m_sharedWebGraphicsContext3D; |
| 5794 } |
| 5795 |
| 5796 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 5797 { |
| 5798 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; |
| 5799 } |
| 5800 #else |
| 5801 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 5802 { |
| 5803 return m_drawingBuffer.get(); |
| 5804 } |
| 5805 #endif |
| 5806 |
| 5704 } // namespace WebCore | 5807 } // namespace WebCore |
| OLD | NEW |