Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/html/canvas/WebGLRenderingContext.h" | 27 #include "core/html/canvas/WebGLRenderingContextBase.h" |
| 28 | 28 |
| 29 #include "RuntimeEnabledFeatures.h" | 29 #include "RuntimeEnabledFeatures.h" |
| 30 #include "bindings/v8/ExceptionMessages.h" | 30 #include "bindings/v8/ExceptionMessages.h" |
| 31 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/fetch/ImageResource.h" | 33 #include "core/fetch/ImageResource.h" |
| 34 #include "core/html/HTMLCanvasElement.h" | 34 #include "core/html/HTMLCanvasElement.h" |
| 35 #include "core/html/HTMLImageElement.h" | 35 #include "core/html/HTMLImageElement.h" |
| 36 #include "core/html/HTMLVideoElement.h" | 36 #include "core/html/HTMLVideoElement.h" |
| 37 #include "core/html/ImageData.h" | 37 #include "core/html/ImageData.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 #include "wtf/PassOwnArrayPtr.h" | 82 #include "wtf/PassOwnArrayPtr.h" |
| 83 #include "wtf/Uint32Array.h" | 83 #include "wtf/Uint32Array.h" |
| 84 #include "wtf/text/StringBuilder.h" | 84 #include "wtf/text/StringBuilder.h" |
| 85 | 85 |
| 86 namespace WebCore { | 86 namespace WebCore { |
| 87 | 87 |
| 88 const double secondsBetweenRestoreAttempts = 1.0; | 88 const double secondsBetweenRestoreAttempts = 1.0; |
| 89 const int maxGLErrorsAllowedToConsole = 256; | 89 const int maxGLErrorsAllowedToConsole = 256; |
| 90 const int maxGLActiveContexts = 16; | 90 const int maxGLActiveContexts = 16; |
| 91 | 91 |
| 92 Vector<WebGLRenderingContext*>& WebGLRenderingContext::activeContexts() | 92 Vector<WebGLRenderingContextBase*>& WebGLRenderingContextBase::activeContexts() |
| 93 { | 93 { |
| 94 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContext*>, activeContexts, ()); | 94 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContextBase*>, activeContexts, ()); |
| 95 return activeContexts; | 95 return activeContexts; |
| 96 } | 96 } |
| 97 | 97 |
| 98 Vector<WebGLRenderingContext*>& WebGLRenderingContext::forciblyEvictedContexts() | 98 Vector<WebGLRenderingContextBase*>& WebGLRenderingContextBase::forciblyEvictedCo ntexts() |
| 99 { | 99 { |
| 100 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContext*>, forciblyEvictedContexts, ()); | 100 DEFINE_STATIC_LOCAL(Vector<WebGLRenderingContextBase*>, forciblyEvictedConte xts, ()); |
| 101 return forciblyEvictedContexts; | 101 return forciblyEvictedContexts; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void WebGLRenderingContext::forciblyLoseOldestContext(const String& reason) | 104 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason) |
| 105 { | 105 { |
| 106 if (activeContexts().size()) { | 106 if (activeContexts().size()) { |
| 107 WebGLRenderingContext* oldestActiveContext = activeContexts().first(); | 107 WebGLRenderingContextBase* oldestActiveContext = activeContexts().first( ); |
| 108 activeContexts().remove(0); | 108 activeContexts().remove(0); |
| 109 | 109 |
| 110 oldestActiveContext->printWarningToConsole(reason); | 110 oldestActiveContext->printWarningToConsole(reason); |
| 111 InspectorInstrumentation::didFireWebGLWarning(oldestActiveContext->canva s()); | 111 InspectorInstrumentation::didFireWebGLWarning(oldestActiveContext->canva s()); |
| 112 | 112 |
| 113 // This will call deactivateContext once the context has actually been l ost. | 113 // This will call deactivateContext once the context has actually been l ost. |
| 114 oldestActiveContext->forceLostContext(WebGLRenderingContext::SyntheticLo stContext); | 114 oldestActiveContext->forceLostContext(WebGLRenderingContextBase::Synthet icLostContext); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 IntSize WebGLRenderingContext::oldestContextSize() | 118 IntSize WebGLRenderingContextBase::oldestContextSize() |
| 119 { | 119 { |
| 120 IntSize size; | 120 IntSize size; |
| 121 | 121 |
| 122 if (activeContexts().size()) { | 122 if (activeContexts().size()) { |
| 123 WebGLRenderingContext* oldestActiveContext = activeContexts().first(); | 123 WebGLRenderingContextBase* oldestActiveContext = activeContexts().first( ); |
| 124 size.setWidth(oldestActiveContext->drawingBufferWidth()); | 124 size.setWidth(oldestActiveContext->drawingBufferWidth()); |
| 125 size.setHeight(oldestActiveContext->drawingBufferHeight()); | 125 size.setHeight(oldestActiveContext->drawingBufferHeight()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 return size; | 128 return size; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void WebGLRenderingContext::activateContext(WebGLRenderingContext* context) | 131 void WebGLRenderingContextBase::activateContext(WebGLRenderingContextBase* conte xt) |
| 132 { | 132 { |
| 133 if (!activeContexts().contains(context)) | 133 if (!activeContexts().contains(context)) |
| 134 activeContexts().append(context); | 134 activeContexts().append(context); |
| 135 | 135 |
| 136 if (activeContexts().size() > maxGLActiveContexts) | 136 if (activeContexts().size() > maxGLActiveContexts) |
| 137 forciblyLoseOldestContext("WARNING: Too many active WebGL contexts. Olde st context will be lost."); | 137 forciblyLoseOldestContext("WARNING: Too many active WebGL contexts. Olde st context will be lost."); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void WebGLRenderingContext::deactivateContext(WebGLRenderingContext* context, bo ol addToEvictedList) | 140 void WebGLRenderingContextBase::deactivateContext(WebGLRenderingContextBase* con text, bool addToEvictedList) |
| 141 { | 141 { |
| 142 size_t position = activeContexts().find(context); | 142 size_t position = activeContexts().find(context); |
| 143 if (position != WTF::notFound) | 143 if (position != WTF::notFound) |
| 144 activeContexts().remove(position); | 144 activeContexts().remove(position); |
| 145 | 145 |
| 146 if (addToEvictedList && !forciblyEvictedContexts().contains(context)) | 146 if (addToEvictedList && !forciblyEvictedContexts().contains(context)) |
| 147 forciblyEvictedContexts().append(context); | 147 forciblyEvictedContexts().append(context); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void WebGLRenderingContext::willDestroyContext(WebGLRenderingContext* context) | 150 void WebGLRenderingContextBase::willDestroyContext(WebGLRenderingContextBase* co ntext) |
| 151 { | 151 { |
| 152 size_t position = forciblyEvictedContexts().find(context); | 152 size_t position = forciblyEvictedContexts().find(context); |
| 153 if (position != WTF::notFound) | 153 if (position != WTF::notFound) |
| 154 forciblyEvictedContexts().remove(position); | 154 forciblyEvictedContexts().remove(position); |
| 155 | 155 |
| 156 deactivateContext(context, false); | 156 deactivateContext(context, false); |
| 157 | 157 |
| 158 // Try to re-enable the oldest inactive contexts. | 158 // Try to re-enable the oldest inactive contexts. |
| 159 while(activeContexts().size() < maxGLActiveContexts && forciblyEvictedContex ts().size()) { | 159 while (activeContexts().size() < maxGLActiveContexts && forciblyEvictedConte xts().size()) { |
| 160 WebGLRenderingContext* evictedContext = forciblyEvictedContexts().first( ); | 160 WebGLRenderingContextBase* evictedContext = forciblyEvictedContexts().fi rst(); |
| 161 if (!evictedContext->m_restoreAllowed) { | 161 if (!evictedContext->m_restoreAllowed) { |
| 162 forciblyEvictedContexts().remove(0); | 162 forciblyEvictedContexts().remove(0); |
| 163 continue; | 163 continue; |
| 164 } | 164 } |
| 165 | 165 |
| 166 IntSize desiredSize = evictedContext->m_drawingBuffer->adjustSize(evicte dContext->clampedCanvasSize()); | 166 IntSize desiredSize = evictedContext->m_drawingBuffer->adjustSize(evicte dContext->clampedCanvasSize()); |
| 167 | 167 |
| 168 // If there's room in the pixel budget for this context, restore it. | 168 // If there's room in the pixel budget for this context, restore it. |
| 169 if (!desiredSize.isEmpty()) { | 169 if (!desiredSize.isEmpty()) { |
| 170 forciblyEvictedContexts().remove(0); | 170 forciblyEvictedContexts().remove(0); |
| 171 evictedContext->forceRestoreContext(); | 171 evictedContext->forceRestoreContext(); |
| 172 activeContexts().append(evictedContext); | 172 activeContexts().append(evictedContext); |
| 173 } | 173 } |
| 174 break; | 174 break; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 class WebGLRenderingContextEvictionManager : public ContextEvictionManager { | 178 class WebGLRenderingContextEvictionManager : public ContextEvictionManager { |
| 179 public: | 179 public: |
| 180 void forciblyLoseOldestContext(const String& reason) { | 180 void forciblyLoseOldestContext(const String& reason) |
| 181 WebGLRenderingContext::forciblyLoseOldestContext(reason); | 181 { |
| 182 WebGLRenderingContextBase::forciblyLoseOldestContext(reason); | |
| 182 }; | 183 }; |
| 183 IntSize oldestContextSize() { | 184 IntSize oldestContextSize() |
| 184 return WebGLRenderingContext::oldestContextSize(); | 185 { |
| 186 return WebGLRenderingContextBase::oldestContextSize(); | |
| 185 }; | 187 }; |
| 186 }; | 188 }; |
| 187 | 189 |
| 188 namespace { | 190 namespace { |
| 189 | 191 |
| 190 class ScopedDrawingBufferBinder { | 192 class ScopedDrawingBufferBinder { |
| 191 public: | 193 public: |
| 192 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) | 194 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) |
| 193 : m_drawingBuffer(drawingBuffer) | 195 : m_drawingBuffer(drawingBuffer) |
| 194 , m_framebufferBinding(framebufferBinding) | 196 , m_framebufferBinding(framebufferBinding) |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 224 } | 226 } |
| 225 GC3Dint end = start + range; | 227 GC3Dint end = start + range; |
| 226 if (end > sourceRange) | 228 if (end > sourceRange) |
| 227 range -= end - sourceRange; | 229 range -= end - sourceRange; |
| 228 *clippedStart = start; | 230 *clippedStart = start; |
| 229 *clippedRange = range; | 231 *clippedRange = range; |
| 230 } | 232 } |
| 231 | 233 |
| 232 // Returns false if no clipping is necessary, i.e., x, y, width, height stay the same. | 234 // Returns false if no clipping is necessary, i.e., x, y, width, height stay the same. |
| 233 bool clip2D(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, | 235 bool clip2D(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, |
| 234 GC3Dsizei sourceWidth, GC3Dsizei sourceHeight, | 236 GC3Dsizei sourceWidth, GC3Dsizei sourceHeight, |
| 235 GC3Dint* clippedX, GC3Dint* clippedY, GC3Dsizei* clippedWidth, G C3Dsizei*clippedHeight) | 237 GC3Dint* clippedX, GC3Dint* clippedY, GC3Dsizei* clippedWidth, GC3Dsizei *clippedHeight) |
| 236 { | 238 { |
| 237 ASSERT(clippedX && clippedY && clippedWidth && clippedHeight); | 239 ASSERT(clippedX && clippedY && clippedWidth && clippedHeight); |
| 238 clip1D(x, width, sourceWidth, clippedX, clippedWidth); | 240 clip1D(x, width, sourceWidth, clippedX, clippedWidth); |
| 239 clip1D(y, height, sourceHeight, clippedY, clippedHeight); | 241 clip1D(y, height, sourceHeight, clippedY, clippedHeight); |
| 240 return (*clippedX != x || *clippedY != y || *clippedWidth != width || *c lippedHeight != height); | 242 return (*clippedX != x || *clippedY != y || *clippedWidth != width || *c lippedHeight != height); |
| 241 } | 243 } |
| 242 | 244 |
| 243 GC3Dint clamp(GC3Dint value, GC3Dint min, GC3Dint max) | 245 GC3Dint clamp(GC3Dint value, GC3Dint min, GC3Dint max) |
| 244 { | 246 { |
| 245 if (value < min) | 247 if (value < min) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 advance(); | 449 advance(); |
| 448 break; | 450 break; |
| 449 } | 451 } |
| 450 | 452 |
| 451 // Swallow all other characters. Unclear whether we may | 453 // Swallow all other characters. Unclear whether we may |
| 452 // want or need to just emit a space per character to try | 454 // want or need to just emit a space per character to try |
| 453 // to preserve column numbers for debugging purposes. | 455 // to preserve column numbers for debugging purposes. |
| 454 break; | 456 break; |
| 455 } | 457 } |
| 456 } | 458 } |
| 457 | |
| 458 GraphicsContext3D::Attributes adjustAttributes(const GraphicsContext3D::Attr ibutes& attributes, Settings* settings) | |
| 459 { | |
| 460 GraphicsContext3D::Attributes adjustedAttributes = attributes; | |
| 461 if (adjustedAttributes.antialias) { | |
| 462 if (settings && !settings->openGLMultisamplingEnabled()) | |
| 463 adjustedAttributes.antialias = false; | |
| 464 } | |
| 465 | |
| 466 return adjustedAttributes; | |
| 467 } | |
| 468 } // namespace anonymous | 459 } // namespace anonymous |
| 469 | 460 |
| 470 class WebGLRenderingContextLostCallback : public GraphicsContext3D::ContextLostC allback { | 461 class WebGLRenderingContextLostCallback : public GraphicsContext3D::ContextLostC allback { |
| 471 WTF_MAKE_FAST_ALLOCATED; | 462 WTF_MAKE_FAST_ALLOCATED; |
| 472 public: | 463 public: |
| 473 explicit WebGLRenderingContextLostCallback(WebGLRenderingContext* cb) : m_co ntext(cb) { } | 464 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* cb) : m_context(cb) { } |
| 474 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon text::RealLostContext); } | 465 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext); } |
| 475 virtual ~WebGLRenderingContextLostCallback() {} | 466 virtual ~WebGLRenderingContextLostCallback() { } |
| 476 private: | 467 private: |
| 477 WebGLRenderingContext* m_context; | 468 WebGLRenderingContextBase* m_context; |
| 478 }; | 469 }; |
| 479 | 470 |
| 480 class WebGLRenderingContextErrorMessageCallback : public GraphicsContext3D::Erro rMessageCallback { | 471 class WebGLRenderingContextErrorMessageCallback : public GraphicsContext3D::Erro rMessageCallback { |
| 481 WTF_MAKE_FAST_ALLOCATED; | 472 WTF_MAKE_FAST_ALLOCATED; |
| 482 public: | 473 public: |
| 483 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContext* cb ) : m_context(cb) { } | 474 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase * cb) : m_context(cb) { } |
| 484 virtual void onErrorMessage(const String& message, GC3Dint) | 475 virtual void onErrorMessage(const String& message, GC3Dint) |
| 485 { | 476 { |
| 486 if (m_context->m_synthesizedErrorsToConsole) | 477 if (m_context->m_synthesizedErrorsToConsole) |
| 487 m_context->printGLErrorToConsole(message); | 478 m_context->printGLErrorToConsole(message); |
| 488 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message); | 479 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message); |
| 489 } | 480 } |
| 490 virtual ~WebGLRenderingContextErrorMessageCallback() { } | 481 virtual ~WebGLRenderingContextErrorMessageCallback() { } |
| 491 private: | 482 private: |
| 492 WebGLRenderingContext* m_context; | 483 WebGLRenderingContextBase* m_context; |
| 493 }; | 484 }; |
| 494 | 485 |
| 495 PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen t* canvas, WebGLContextAttributes* attrs) | 486 GraphicsContext3D::Attributes WebGLRenderingContextBase::adjustAttributes(const GraphicsContext3D::Attributes& attributes, Settings* settings) |
| 496 { | 487 { |
| 497 Document& document = canvas->document(); | 488 GraphicsContext3D::Attributes adjustedAttributes = attributes; |
| 498 Frame* frame = document.frame(); | 489 if (adjustedAttributes.antialias) { |
| 499 if (!frame) | 490 if (settings && !settings->openGLMultisamplingEnabled()) |
| 500 return nullptr; | 491 adjustedAttributes.antialias = false; |
| 501 Settings* settings = frame->settings(); | |
| 502 | |
| 503 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in | |
| 504 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension. | |
| 505 if (!frame->loader()->client()->allowWebGL(settings && settings->webGLEnable d())) { | |
| 506 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Web page was not allowed to create a WebGL co ntext.")); | |
| 507 return nullptr; | |
| 508 } | 492 } |
| 509 | 493 |
| 510 GraphicsContext3D::Attributes requestedAttributes = attrs ? attrs->attribute s() : GraphicsContext3D::Attributes(); | 494 return adjustedAttributes; |
| 511 requestedAttributes.noExtensions = true; | |
| 512 requestedAttributes.shareResources = true; | |
| 513 requestedAttributes.preferDiscreteGPU = true; | |
| 514 requestedAttributes.topDocumentURL = document.topDocument()->url(); | |
| 515 | |
| 516 GraphicsContext3D::Attributes attributes = adjustAttributes(requestedAttribu tes, settings); | |
| 517 | |
| 518 RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attributes)); | |
| 519 | |
| 520 if (!context || !context->makeContextCurrent()) { | |
| 521 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Could not create a WebGL context.")); | |
| 522 return nullptr; | |
| 523 } | |
| 524 | |
| 525 Extensions3D* extensions = context->getExtensions(); | |
| 526 if (extensions->supports("GL_EXT_debug_marker")) | |
| 527 extensions->pushGroupMarkerEXT("WebGLRenderingContext"); | |
| 528 | |
| 529 OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRendering Context(canvas, context, attributes, requestedAttributes)); | |
| 530 renderingContext->suspendIfNeeded(); | |
| 531 | |
| 532 if (renderingContext->m_drawingBuffer->isZeroSized()) { | |
| 533 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Could not create a WebGL context.")); | |
| 534 return nullptr; | |
| 535 } | |
| 536 | |
| 537 return renderingContext.release(); | |
| 538 } | 495 } |
| 539 | 496 |
| 540 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa ssRefPtr<GraphicsContext3D> context, GraphicsContext3D::Attributes attributes, G raphicsContext3D::Attributes requestedAttributes) | 497 WebGLRenderingContextBase::WebGLRenderingContextBase(const String& contextName, unsigned featureLevel, HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsConte xt3D> context, GraphicsContext3D::Attributes attributes, GraphicsContext3D::Attr ibutes requestedAttributes) |
| 541 : CanvasRenderingContext(passedCanvas) | 498 : CanvasRenderingContext(passedCanvas) |
| 542 , ActiveDOMObject(&passedCanvas->document()) | 499 , ActiveDOMObject(&passedCanvas->document()) |
| 500 , m_contextName(contextName) | |
| 501 , m_featureLevel(featureLevel) | |
|
bajones
2013/09/24 00:12:01
This would be the feature level indicator that @zm
| |
| 543 , m_context(context) | 502 , m_context(context) |
| 544 , m_drawingBuffer(0) | 503 , m_drawingBuffer(0) |
| 545 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont extLostEvent) | 504 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) |
| 546 , m_restoreAllowed(false) | 505 , m_restoreAllowed(false) |
| 547 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext) | 506 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
| 548 , m_videoCache(4) | 507 , m_videoCache(4) |
| 549 , m_contextLost(false) | 508 , m_contextLost(false) |
| 550 , m_contextLostMode(SyntheticLostContext) | 509 , m_contextLostMode(SyntheticLostContext) |
| 551 , m_attributes(attributes) | 510 , m_attributes(attributes) |
| 552 , m_requestedAttributes(requestedAttributes) | 511 , m_requestedAttributes(requestedAttributes) |
| 553 , m_synthesizedErrorsToConsole(true) | 512 , m_synthesizedErrorsToConsole(true) |
| 554 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 513 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
| 555 , m_multisamplingAllowed(false) | 514 , m_multisamplingAllowed(false) |
| 556 , m_multisamplingObserverRegistered(false) | 515 , m_multisamplingObserverRegistered(false) |
| 557 , m_onePlusMaxEnabledAttribIndex(0) | 516 , m_onePlusMaxEnabledAttribIndex(0) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 570 | 529 |
| 571 // Create the DrawingBuffer and initialize the platform layer. | 530 // Create the DrawingBuffer and initialize the platform layer. |
| 572 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 531 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 573 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release()); | 532 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release()); |
| 574 | 533 |
| 575 if (!m_drawingBuffer->isZeroSized()) { | 534 if (!m_drawingBuffer->isZeroSized()) { |
| 576 m_drawingBuffer->bind(); | 535 m_drawingBuffer->bind(); |
| 577 setupFlags(); | 536 setupFlags(); |
| 578 initializeNewContext(); | 537 initializeNewContext(); |
| 579 } | 538 } |
| 580 | |
| 581 // Register extensions. | |
| 582 static const char* webkitPrefix[] = { "WEBKIT_", 0, }; | |
| 583 static const char* bothPrefixes[] = { "", "WEBKIT_", 0, }; | |
| 584 | |
| 585 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); | |
| 586 registerExtension<EXTTextureFilterAnisotropic>(m_extTextureFilterAnisotropic , PrefixedExtension, webkitPrefix); | |
| 587 registerExtension<OESElementIndexUint>(m_oesElementIndexUint); | |
| 588 registerExtension<OESStandardDerivatives>(m_oesStandardDerivatives); | |
| 589 registerExtension<OESTextureFloat>(m_oesTextureFloat); | |
| 590 registerExtension<OESTextureFloatLinear>(m_oesTextureFloatLinear); | |
| 591 registerExtension<OESTextureHalfFloat>(m_oesTextureHalfFloat); | |
| 592 registerExtension<OESTextureHalfFloatLinear>(m_oesTextureHalfFloatLinear); | |
| 593 registerExtension<OESVertexArrayObject>(m_oesVertexArrayObject); | |
| 594 registerExtension<WebGLCompressedTextureATC>(m_webglCompressedTextureATC, Pr efixedExtension, webkitPrefix); | |
| 595 registerExtension<WebGLCompressedTexturePVRTC>(m_webglCompressedTexturePVRTC , PrefixedExtension, webkitPrefix); | |
| 596 registerExtension<WebGLCompressedTextureS3TC>(m_webglCompressedTextureS3TC, PrefixedExtension, bothPrefixes); | |
| 597 registerExtension<WebGLDepthTexture>(m_webglDepthTexture, PrefixedExtension, bothPrefixes); | |
| 598 registerExtension<WebGLLoseContext>(m_webglLoseContext, ApprovedExtension, b othPrefixes); | |
| 599 | |
| 600 // Register draft extensions. | |
| 601 registerExtension<EXTFragDepth>(m_extFragDepth, DraftExtension); | |
| 602 registerExtension<WebGLDrawBuffers>(m_webglDrawBuffers, DraftExtension); | |
| 603 | |
| 604 // Register privileged extensions. | |
| 605 registerExtension<WebGLDebugRendererInfo>(m_webglDebugRendererInfo, Privileg edExtension); | |
| 606 registerExtension<WebGLDebugShaders>(m_webglDebugShaders, PrivilegedExtensio n); | |
| 607 } | 539 } |
| 608 | 540 |
| 609 void WebGLRenderingContext::initializeNewContext() | 541 void WebGLRenderingContextBase::initializeNewContext() |
| 610 { | 542 { |
| 611 ASSERT(!isContextLost()); | 543 ASSERT(!isContextLost()); |
| 612 m_needsUpdate = true; | 544 m_needsUpdate = true; |
| 613 m_markedCanvasDirty = false; | 545 m_markedCanvasDirty = false; |
| 614 m_activeTextureUnit = 0; | 546 m_activeTextureUnit = 0; |
| 615 m_packAlignment = 4; | 547 m_packAlignment = 4; |
| 616 m_unpackAlignment = 4; | 548 m_unpackAlignment = 4; |
| 617 m_unpackFlipY = false; | 549 m_unpackFlipY = false; |
| 618 m_unpackPremultiplyAlpha = false; | 550 m_unpackPremultiplyAlpha = false; |
| 619 m_unpackColorspaceConversion = GraphicsContext3D::BROWSER_DEFAULT_WEBGL; | 551 m_unpackColorspaceConversion = GraphicsContext3D::BROWSER_DEFAULT_WEBGL; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 | 604 |
| 673 IntSize canvasSize = clampedCanvasSize(); | 605 IntSize canvasSize = clampedCanvasSize(); |
| 674 m_drawingBuffer->reset(canvasSize); | 606 m_drawingBuffer->reset(canvasSize); |
| 675 | 607 |
| 676 m_context->viewport(0, 0, canvasSize.width(), canvasSize.height()); | 608 m_context->viewport(0, 0, canvasSize.width(), canvasSize.height()); |
| 677 m_context->scissor(0, 0, canvasSize.width(), canvasSize.height()); | 609 m_context->scissor(0, 0, canvasSize.width(), canvasSize.height()); |
| 678 | 610 |
| 679 m_context->setContextLostCallback(adoptPtr(new WebGLRenderingContextLostCall back(this))); | 611 m_context->setContextLostCallback(adoptPtr(new WebGLRenderingContextLostCall back(this))); |
| 680 m_context->setErrorMessageCallback(adoptPtr(new WebGLRenderingContextErrorMe ssageCallback(this))); | 612 m_context->setErrorMessageCallback(adoptPtr(new WebGLRenderingContextErrorMe ssageCallback(this))); |
| 681 | 613 |
| 614 for (int i = 0; i < WebGLExtensionNameCount; ++i) | |
| 615 m_extensionEnabled[i] = false; | |
| 616 | |
| 682 activateContext(this); | 617 activateContext(this); |
| 683 } | 618 } |
| 684 | 619 |
| 685 void WebGLRenderingContext::setupFlags() | 620 void WebGLRenderingContextBase::setupFlags() |
| 686 { | 621 { |
| 687 ASSERT(m_context); | 622 ASSERT(m_context); |
| 688 if (Page* p = canvas()->document().page()) { | 623 if (Page* p = canvas()->document().page()) { |
| 689 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled (); | 624 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled (); |
| 690 | 625 |
| 691 if (!m_multisamplingObserverRegistered && m_requestedAttributes.antialia s) { | 626 if (!m_multisamplingObserverRegistered && m_requestedAttributes.antialia s) { |
| 692 m_multisamplingAllowed = m_drawingBuffer->multisample(); | 627 m_multisamplingAllowed = m_drawingBuffer->multisample(); |
| 693 p->addMultisamplingChangedObserver(this); | 628 p->addMultisamplingChangedObserver(this); |
| 694 m_multisamplingObserverRegistered = true; | 629 m_multisamplingObserverRegistered = true; |
| 695 } | 630 } |
| 696 } | 631 } |
| 697 | 632 |
| 698 m_isGLES2NPOTStrict = !m_context->getExtensions()->isEnabled("GL_OES_texture _npot"); | 633 m_isGLES2NPOTStrict = !m_context->getExtensions()->isEnabled("GL_OES_texture _npot"); |
| 699 m_isDepthStencilSupported = m_context->getExtensions()->isEnabled("GL_OES_pa cked_depth_stencil"); | 634 m_isDepthStencilSupported = m_context->getExtensions()->isEnabled("GL_OES_pa cked_depth_stencil"); |
| 700 } | 635 } |
| 701 | 636 |
| 702 bool WebGLRenderingContext::allowPrivilegedExtensions() const | 637 bool WebGLRenderingContextBase::allowPrivilegedExtensions() const |
| 703 { | 638 { |
| 704 if (Page* p = canvas()->document().page()) | 639 if (Page* p = canvas()->document().page()) |
| 705 return p->settings().privilegedWebGLExtensionsEnabled(); | 640 return p->settings().privilegedWebGLExtensionsEnabled(); |
| 706 return false; | 641 return false; |
| 707 } | 642 } |
| 708 | 643 |
| 709 void WebGLRenderingContext::addCompressedTextureFormat(GC3Denum format) | 644 void WebGLRenderingContextBase::addCompressedTextureFormat(GC3Denum format) |
| 710 { | 645 { |
| 711 if (!m_compressedTextureFormats.contains(format)) | 646 if (!m_compressedTextureFormats.contains(format)) |
| 712 m_compressedTextureFormats.append(format); | 647 m_compressedTextureFormats.append(format); |
| 713 } | 648 } |
| 714 | 649 |
| 715 void WebGLRenderingContext::removeAllCompressedTextureFormats() | 650 void WebGLRenderingContextBase::removeAllCompressedTextureFormats() |
| 716 { | 651 { |
| 717 m_compressedTextureFormats.clear(); | 652 m_compressedTextureFormats.clear(); |
| 718 } | 653 } |
| 719 | 654 |
| 720 WebGLRenderingContext::~WebGLRenderingContext() | 655 WebGLRenderingContextBase::~WebGLRenderingContextBase() |
| 721 { | 656 { |
| 722 // Remove all references to WebGLObjects so if they are the last reference | 657 // Remove all references to WebGLObjects so if they are the last reference |
| 723 // they will be freed before the last context is removed from the context gr oup. | 658 // they will be freed before the last context is removed from the context gr oup. |
| 724 m_boundArrayBuffer = 0; | 659 m_boundArrayBuffer = 0; |
| 725 m_defaultVertexArrayObject = 0; | 660 m_defaultVertexArrayObject = 0; |
| 726 m_boundVertexArrayObject = 0; | 661 m_boundVertexArrayObject = 0; |
| 727 m_vertexAttrib0Buffer = 0; | 662 m_vertexAttrib0Buffer = 0; |
| 728 m_currentProgram = 0; | 663 m_currentProgram = 0; |
| 729 m_framebufferBinding = 0; | 664 m_framebufferBinding = 0; |
| 730 m_renderbufferBinding = 0; | 665 m_renderbufferBinding = 0; |
| 731 | 666 |
| 732 for (size_t i = 0; i < m_textureUnits.size(); ++i) { | 667 for (size_t i = 0; i < m_textureUnits.size(); ++i) { |
| 733 m_textureUnits[i].m_texture2DBinding = 0; | 668 m_textureUnits[i].m_texture2DBinding = 0; |
| 734 m_textureUnits[i].m_textureCubeMapBinding = 0; | 669 m_textureUnits[i].m_textureCubeMapBinding = 0; |
| 735 } | 670 } |
| 736 | 671 |
| 737 m_blackTexture2D = 0; | 672 m_blackTexture2D = 0; |
| 738 m_blackTextureCubeMap = 0; | 673 m_blackTextureCubeMap = 0; |
| 739 | 674 |
| 740 detachAndRemoveAllObjects(); | 675 detachAndRemoveAllObjects(); |
| 741 | 676 |
| 742 // release all extensions | 677 // release all extensions |
| 743 for (size_t i = 0; i < m_extensions.size(); ++i) | 678 for (size_t i = 0; i < m_extensions.size(); ++i) |
| 744 delete m_extensions[i]; | 679 delete m_extensions[i]; |
| 745 | 680 |
| 746 // Context must be removed from the group prior to the destruction of the | 681 // Context must be removed from the group prior to the destruction of the |
| 747 // GraphicsContext3D, otherwise shared objects may not be properly deleted. | 682 // GraphicsContext3D, otherwise shared objects may not be properly deleted. |
| 748 m_contextGroup->removeContext(this); | 683 m_contextGroup->removeContext(this); |
| 749 | 684 |
| 750 destroyGraphicsContext3D(); | 685 destroyGraphicsContext3D(); |
| 751 | 686 |
| 752 if (m_multisamplingObserverRegistered) { | 687 if (m_multisamplingObserverRegistered) { |
| 753 Page* page = canvas()->document().page(); | 688 Page* page = canvas()->document().page(); |
| 754 if (page) | 689 if (page) |
| 755 page->removeMultisamplingChangedObserver(this); | 690 page->removeMultisamplingChangedObserver(this); |
| 756 } | 691 } |
| 757 | 692 |
| 758 willDestroyContext(this); | 693 willDestroyContext(this); |
| 759 } | 694 } |
| 760 | 695 |
| 761 void WebGLRenderingContext::destroyGraphicsContext3D() | 696 void WebGLRenderingContextBase::destroyGraphicsContext3D() |
| 762 { | 697 { |
| 763 m_contextLost = true; | 698 m_contextLost = true; |
| 764 | 699 |
| 765 // The drawing buffer holds a context reference. It must also be destroyed | 700 // The drawing buffer holds a context reference. It must also be destroyed |
| 766 // in order for the context to be released. | 701 // in order for the context to be released. |
| 767 m_drawingBuffer->releaseResources(); | 702 m_drawingBuffer->releaseResources(); |
| 768 | 703 |
| 769 if (m_context) { | 704 if (m_context) { |
| 770 m_context->setContextLostCallback(nullptr); | 705 m_context->setContextLostCallback(nullptr); |
| 771 m_context->setErrorMessageCallback(nullptr); | 706 m_context->setErrorMessageCallback(nullptr); |
| 772 m_context.clear(); | 707 m_context.clear(); |
| 773 } | 708 } |
| 774 } | 709 } |
| 775 | 710 |
| 776 void WebGLRenderingContext::markContextChanged() | 711 void WebGLRenderingContextBase::markContextChanged() |
| 777 { | 712 { |
| 778 if (m_framebufferBinding || isContextLost()) | 713 if (m_framebufferBinding || isContextLost()) |
| 779 return; | 714 return; |
| 780 | 715 |
| 781 m_context->markContextChanged(); | 716 m_context->markContextChanged(); |
| 782 m_drawingBuffer->markContentsChanged(); | 717 m_drawingBuffer->markContentsChanged(); |
| 783 | 718 |
| 784 m_layerCleared = false; | 719 m_layerCleared = false; |
| 785 RenderBox* renderBox = canvas()->renderBox(); | 720 RenderBox* renderBox = canvas()->renderBox(); |
| 786 if (renderBox && renderBox->hasAcceleratedCompositing()) { | 721 if (renderBox && renderBox->hasAcceleratedCompositing()) { |
| 787 m_markedCanvasDirty = true; | 722 m_markedCanvasDirty = true; |
| 788 canvas()->clearCopiedImage(); | 723 canvas()->clearCopiedImage(); |
| 789 renderBox->contentChanged(CanvasChanged); | 724 renderBox->contentChanged(CanvasChanged); |
| 790 } else { | 725 } else { |
| 791 if (!m_markedCanvasDirty) { | 726 if (!m_markedCanvasDirty) { |
| 792 m_markedCanvasDirty = true; | 727 m_markedCanvasDirty = true; |
| 793 canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); | 728 canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); |
| 794 } | 729 } |
| 795 } | 730 } |
| 796 } | 731 } |
| 797 | 732 |
| 798 bool WebGLRenderingContext::clearIfComposited(GC3Dbitfield mask) | 733 bool WebGLRenderingContextBase::clearIfComposited(GC3Dbitfield mask) |
| 799 { | 734 { |
| 800 if (isContextLost()) | 735 if (isContextLost()) |
| 801 return false; | 736 return false; |
| 802 | 737 |
| 803 if (!m_context->layerComposited() || m_layerCleared | 738 if (!m_context->layerComposited() || m_layerCleared |
| 804 || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding)) | 739 || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding)) |
| 805 return false; | 740 return false; |
| 806 | 741 |
| 807 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); | 742 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); |
| 808 | 743 |
| 809 // Determine if it's possible to combine the clear the user asked for and th is clear. | 744 // Determine if it's possible to combine the clear the user asked for and th is clear. |
| 810 bool combinedClear = mask && !m_scissorEnabled; | 745 bool combinedClear = mask && !m_scissorEnabled; |
| 811 | 746 |
| 812 m_context->disable(GraphicsContext3D::SCISSOR_TEST); | 747 m_context->disable(GraphicsContext3D::SCISSOR_TEST); |
| 813 if (combinedClear && (mask & GraphicsContext3D::COLOR_BUFFER_BIT)) | 748 if (combinedClear && (mask & GraphicsContext3D::COLOR_BUFFER_BIT)) { |
| 814 m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 749 m_context->clearColor( |
| 815 m_colorMask[1] ? m_clearColor[1] : 0, | 750 m_colorMask[0] ? m_clearColor[0] : 0, |
| 816 m_colorMask[2] ? m_clearColor[2] : 0, | 751 m_colorMask[1] ? m_clearColor[1] : 0, |
| 817 m_colorMask[3] ? m_clearColor[3] : 0); | 752 m_colorMask[2] ? m_clearColor[2] : 0, |
| 818 else | 753 m_colorMask[3] ? m_clearColor[3] : 0); |
| 754 } else { | |
| 819 m_context->clearColor(0, 0, 0, 0); | 755 m_context->clearColor(0, 0, 0, 0); |
| 756 } | |
| 820 m_context->colorMask(true, true, true, true); | 757 m_context->colorMask(true, true, true, true); |
| 821 GC3Dbitfield clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; | 758 GC3Dbitfield clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; |
| 822 if (contextAttributes->depth()) { | 759 if (contextAttributes->depth()) { |
| 823 if (!combinedClear || !m_depthMask || !(mask & GraphicsContext3D::DEPTH_ BUFFER_BIT)) | 760 if (!combinedClear || !m_depthMask || !(mask & GraphicsContext3D::DEPTH_ BUFFER_BIT)) |
| 824 m_context->clearDepth(1.0f); | 761 m_context->clearDepth(1.0f); |
| 825 clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; | 762 clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; |
| 826 m_context->depthMask(true); | 763 m_context->depthMask(true); |
| 827 } | 764 } |
| 828 if (contextAttributes->stencil()) { | 765 if (contextAttributes->stencil()) { |
| 829 if (combinedClear && (mask & GraphicsContext3D::STENCIL_BUFFER_BIT)) | 766 if (combinedClear && (mask & GraphicsContext3D::STENCIL_BUFFER_BIT)) |
| 830 m_context->clearStencil(m_clearStencil & m_stencilMask); | 767 m_context->clearStencil(m_clearStencil & m_stencilMask); |
| 831 else | 768 else |
| 832 m_context->clearStencil(0); | 769 m_context->clearStencil(0); |
| 833 clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; | 770 clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; |
| 834 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xFFFFFFFF); | 771 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xFFFFFFFF); |
| 835 } | 772 } |
| 836 | 773 |
| 837 m_drawingBuffer->clearFramebuffers(clearMask); | 774 m_drawingBuffer->clearFramebuffers(clearMask); |
| 838 | 775 |
| 839 restoreStateAfterClear(); | 776 restoreStateAfterClear(); |
| 840 if (m_framebufferBinding) | 777 if (m_framebufferBinding) |
| 841 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); | 778 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); |
| 842 m_layerCleared = true; | 779 m_layerCleared = true; |
| 843 | 780 |
| 844 return combinedClear; | 781 return combinedClear; |
| 845 } | 782 } |
| 846 | 783 |
| 847 void WebGLRenderingContext::restoreStateAfterClear() | 784 void WebGLRenderingContextBase::restoreStateAfterClear() |
| 848 { | 785 { |
| 849 if (isContextLost()) | 786 if (isContextLost()) |
| 850 return; | 787 return; |
| 851 | 788 |
| 852 // Restore the state that the context set. | 789 // Restore the state that the context set. |
| 853 if (m_scissorEnabled) | 790 if (m_scissorEnabled) |
| 854 m_context->enable(GraphicsContext3D::SCISSOR_TEST); | 791 m_context->enable(GraphicsContext3D::SCISSOR_TEST); |
| 855 m_context->clearColor(m_clearColor[0], m_clearColor[1], | 792 m_context->clearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], m_c learColor[3]); |
| 856 m_clearColor[2], m_clearColor[3]); | 793 m_context->colorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_color Mask[3]); |
| 857 m_context->colorMask(m_colorMask[0], m_colorMask[1], | |
| 858 m_colorMask[2], m_colorMask[3]); | |
| 859 m_context->clearDepth(m_clearDepth); | 794 m_context->clearDepth(m_clearDepth); |
| 860 m_context->clearStencil(m_clearStencil); | 795 m_context->clearStencil(m_clearStencil); |
| 861 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, m_stencilMask); | 796 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, m_stencilMask); |
| 862 m_context->depthMask(m_depthMask); | 797 m_context->depthMask(m_depthMask); |
| 863 } | 798 } |
| 864 | 799 |
| 865 void WebGLRenderingContext::markLayerComposited() | 800 void WebGLRenderingContextBase::markLayerComposited() |
| 866 { | 801 { |
| 867 if (!isContextLost()) | 802 if (!isContextLost()) |
| 868 m_context->markLayerComposited(); | 803 m_context->markLayerComposited(); |
| 869 } | 804 } |
| 870 | 805 |
| 871 void WebGLRenderingContext::paintRenderingResultsToCanvas() | 806 void WebGLRenderingContextBase::paintRenderingResultsToCanvas() |
| 872 { | 807 { |
| 873 if (isContextLost()) { | 808 if (isContextLost()) { |
| 874 canvas()->clearPresentationCopy(); | 809 canvas()->clearPresentationCopy(); |
| 875 return; | 810 return; |
| 876 } | 811 } |
| 877 | 812 |
| 878 if (canvas()->document().printing()) | 813 if (canvas()->document().printing()) |
| 879 canvas()->clearPresentationCopy(); | 814 canvas()->clearPresentationCopy(); |
| 880 | 815 |
| 881 // Until the canvas is written to by the application, the clear that | 816 // Until the canvas is written to by the application, the clear that |
| 882 // happened after it was composited should be ignored by the compositor. | 817 // happened after it was composited should be ignored by the compositor. |
| 883 if (m_context->layerComposited() && !m_attributes.preserveDrawingBuffer) { | 818 if (m_context->layerComposited() && !m_attributes.preserveDrawingBuffer) { |
| 884 m_drawingBuffer->paintCompositedResultsToCanvas(canvas()->buffer()); | 819 m_drawingBuffer->paintCompositedResultsToCanvas(canvas()->buffer()); |
| 885 | 820 |
| 886 canvas()->makePresentationCopy(); | 821 canvas()->makePresentationCopy(); |
| 887 } else | 822 } else { |
| 888 canvas()->clearPresentationCopy(); | 823 canvas()->clearPresentationCopy(); |
| 824 } | |
| 889 clearIfComposited(); | 825 clearIfComposited(); |
| 890 | 826 |
| 891 if (!m_markedCanvasDirty && !m_layerCleared) | 827 if (!m_markedCanvasDirty && !m_layerCleared) |
| 892 return; | 828 return; |
| 893 | 829 |
| 894 canvas()->clearCopiedImage(); | 830 canvas()->clearCopiedImage(); |
| 895 m_markedCanvasDirty = false; | 831 m_markedCanvasDirty = false; |
| 896 | 832 |
| 897 m_drawingBuffer->commit(); | 833 m_drawingBuffer->commit(); |
| 898 m_context->paintRenderingResultsToCanvas(canvas()->buffer(), m_drawingBuffer .get()); | 834 m_context->paintRenderingResultsToCanvas(canvas()->buffer(), m_drawingBuffer .get()); |
| 899 | 835 |
| 900 if (m_framebufferBinding) | 836 if (m_framebufferBinding) |
| 901 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); | 837 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); |
| 902 else | 838 else |
| 903 m_drawingBuffer->bind(); | 839 m_drawingBuffer->bind(); |
| 904 } | 840 } |
| 905 | 841 |
| 906 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() | 842 PassRefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageDat a() |
| 907 { | 843 { |
| 908 if (isContextLost()) | 844 if (isContextLost()) |
| 909 return 0; | 845 return 0; |
| 910 | 846 |
| 911 clearIfComposited(); | 847 clearIfComposited(); |
| 912 m_drawingBuffer->commit(); | 848 m_drawingBuffer->commit(); |
| 913 RefPtr<ImageData> imageData = m_context->paintRenderingResultsToImageData(m_ drawingBuffer.get()); | 849 RefPtr<ImageData> imageData = m_context->paintRenderingResultsToImageData(m_ drawingBuffer.get()); |
| 914 | 850 |
| 915 if (m_framebufferBinding) | 851 if (m_framebufferBinding) |
| 916 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); | 852 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); |
| 917 else | 853 else |
| 918 m_drawingBuffer->bind(); | 854 m_drawingBuffer->bind(); |
| 919 | 855 |
| 920 return imageData; | 856 return imageData; |
| 921 } | 857 } |
| 922 | 858 |
| 923 void WebGLRenderingContext::reshape(int width, int height) | 859 void WebGLRenderingContextBase::reshape(int width, int height) |
| 924 { | 860 { |
| 925 if (isContextLost()) | 861 if (isContextLost()) |
| 926 return; | 862 return; |
| 927 | 863 |
| 928 // This is an approximation because at WebGLRenderingContext level we don't | 864 // This is an approximation because at WebGLRenderingContextBase level we do n't |
| 929 // know if the underlying FBO uses textures or renderbuffers. | 865 // know if the underlying FBO uses textures or renderbuffers. |
| 930 GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); | 866 GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); |
| 931 // Limit drawing buffer size to 4k to avoid memory exhaustion. | 867 // Limit drawing buffer size to 4k to avoid memory exhaustion. |
| 932 const int sizeUpperLimit = 4096; | 868 const int sizeUpperLimit = 4096; |
| 933 maxSize = std::min(maxSize, sizeUpperLimit); | 869 maxSize = std::min(maxSize, sizeUpperLimit); |
| 934 GC3Dint maxWidth = std::min(maxSize, m_maxViewportDims[0]); | 870 GC3Dint maxWidth = std::min(maxSize, m_maxViewportDims[0]); |
| 935 GC3Dint maxHeight = std::min(maxSize, m_maxViewportDims[1]); | 871 GC3Dint maxHeight = std::min(maxSize, m_maxViewportDims[1]); |
| 936 width = clamp(width, 1, maxWidth); | 872 width = clamp(width, 1, maxWidth); |
| 937 height = clamp(height, 1, maxHeight); | 873 height = clamp(height, 1, maxHeight); |
| 938 | 874 |
| 939 if (m_needsUpdate) { | 875 if (m_needsUpdate) { |
| 940 RenderBox* renderBox = canvas()->renderBox(); | 876 RenderBox* renderBox = canvas()->renderBox(); |
| 941 if (renderBox && renderBox->hasAcceleratedCompositing()) | 877 if (renderBox && renderBox->hasAcceleratedCompositing()) |
| 942 renderBox->contentChanged(CanvasChanged); | 878 renderBox->contentChanged(CanvasChanged); |
| 943 m_needsUpdate = false; | 879 m_needsUpdate = false; |
| 944 } | 880 } |
| 945 | 881 |
| 946 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off | 882 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off |
| 947 // clear (and this matches what reshape will do). | 883 // clear (and this matches what reshape will do). |
| 948 m_drawingBuffer->reset(IntSize(width, height)); | 884 m_drawingBuffer->reset(IntSize(width, height)); |
| 949 restoreStateAfterClear(); | 885 restoreStateAfterClear(); |
| 950 | 886 |
| 951 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(m_texture Units[m_activeTextureUnit].m_texture2DBinding.get())); | 887 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(m_texture Units[m_activeTextureUnit].m_texture2DBinding.get())); |
| 952 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, objectOrZero(m_ renderbufferBinding.get())); | 888 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, objectOrZero(m_ renderbufferBinding.get())); |
| 953 if (m_framebufferBinding) | 889 if (m_framebufferBinding) |
| 954 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero(m_ framebufferBinding.get())); | 890 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); |
| 955 } | 891 } |
| 956 | 892 |
| 957 int WebGLRenderingContext::drawingBufferWidth() const | 893 int WebGLRenderingContextBase::drawingBufferWidth() const |
| 958 { | 894 { |
| 959 return m_drawingBuffer->size().width(); | 895 return m_drawingBuffer->size().width(); |
| 960 } | 896 } |
| 961 | 897 |
| 962 int WebGLRenderingContext::drawingBufferHeight() const | 898 int WebGLRenderingContextBase::drawingBufferHeight() const |
| 963 { | 899 { |
| 964 return m_drawingBuffer->size().height(); | 900 return m_drawingBuffer->size().height(); |
| 965 } | 901 } |
| 966 | 902 |
| 967 unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type) | 903 unsigned WebGLRenderingContextBase::sizeInBytes(GC3Denum type) |
| 968 { | 904 { |
| 969 switch (type) { | 905 switch (type) { |
| 970 case GraphicsContext3D::BYTE: | 906 case GraphicsContext3D::BYTE: |
| 971 return sizeof(GC3Dbyte); | 907 return sizeof(GC3Dbyte); |
| 972 case GraphicsContext3D::UNSIGNED_BYTE: | 908 case GraphicsContext3D::UNSIGNED_BYTE: |
| 973 return sizeof(GC3Dubyte); | 909 return sizeof(GC3Dubyte); |
| 974 case GraphicsContext3D::SHORT: | 910 case GraphicsContext3D::SHORT: |
| 975 return sizeof(GC3Dshort); | 911 return sizeof(GC3Dshort); |
| 976 case GraphicsContext3D::UNSIGNED_SHORT: | 912 case GraphicsContext3D::UNSIGNED_SHORT: |
| 977 return sizeof(GC3Dushort); | 913 return sizeof(GC3Dushort); |
| 978 case GraphicsContext3D::INT: | 914 case GraphicsContext3D::INT: |
| 979 return sizeof(GC3Dint); | 915 return sizeof(GC3Dint); |
| 980 case GraphicsContext3D::UNSIGNED_INT: | 916 case GraphicsContext3D::UNSIGNED_INT: |
| 981 return sizeof(GC3Duint); | 917 return sizeof(GC3Duint); |
| 982 case GraphicsContext3D::FLOAT: | 918 case GraphicsContext3D::FLOAT: |
| 983 return sizeof(GC3Dfloat); | 919 return sizeof(GC3Dfloat); |
| 984 } | 920 } |
| 985 ASSERT_NOT_REACHED(); | 921 ASSERT_NOT_REACHED(); |
| 986 return 0; | 922 return 0; |
| 987 } | 923 } |
| 988 | 924 |
| 989 void WebGLRenderingContext::activeTexture(GC3Denum texture) | 925 void WebGLRenderingContextBase::activeTexture(GC3Denum texture) |
| 990 { | 926 { |
| 991 if (isContextLost()) | 927 if (isContextLost()) |
| 992 return; | 928 return; |
| 993 if (texture - GraphicsContext3D::TEXTURE0 >= m_textureUnits.size()) { | 929 if (texture - GraphicsContext3D::TEXTURE0 >= m_textureUnits.size()) { |
| 994 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "activeTexture", "tex ture unit out of range"); | 930 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "activeTexture", "tex ture unit out of range"); |
| 995 return; | 931 return; |
| 996 } | 932 } |
| 997 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; | 933 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; |
| 998 m_context->activeTexture(texture); | 934 m_context->activeTexture(texture); |
| 999 | 935 |
| 1000 m_drawingBuffer->setActiveTextureUnit(texture); | 936 m_drawingBuffer->setActiveTextureUnit(texture); |
| 1001 | 937 |
| 1002 } | 938 } |
| 1003 | 939 |
| 1004 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha der) | 940 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader* shader) |
| 1005 { | 941 { |
| 1006 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) | 942 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) |
| 1007 return; | 943 return; |
| 1008 if (!program->attachShader(shader)) { | 944 if (!program->attachShader(shader)) { |
| 1009 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader"); | 945 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader"); |
| 1010 return; | 946 return; |
| 1011 } | 947 } |
| 1012 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); | 948 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); |
| 1013 shader->onAttached(); | 949 shader->onAttached(); |
| 1014 } | 950 } |
| 1015 | 951 |
| 1016 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i ndex, const String& name) | 952 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GC3Dui nt index, const String& name) |
| 1017 { | 953 { |
| 1018 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 954 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) |
| 1019 return; | 955 return; |
| 1020 if (!validateLocationLength("bindAttribLocation", name)) | 956 if (!validateLocationLength("bindAttribLocation", name)) |
| 1021 return; | 957 return; |
| 1022 if (!validateString("bindAttribLocation", name)) | 958 if (!validateString("bindAttribLocation", name)) |
| 1023 return; | 959 return; |
| 1024 if (isPrefixReserved(name)) { | 960 if (isPrefixReserved(name)) { |
| 1025 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat ion", "reserved prefix"); | 961 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat ion", "reserved prefix"); |
| 1026 return; | 962 return; |
| 1027 } | 963 } |
| 1028 if (index >= m_maxVertexAttribs) { | 964 if (index >= m_maxVertexAttribs) { |
| 1029 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation" , "index out of range"); | 965 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation" , "index out of range"); |
| 1030 return; | 966 return; |
| 1031 } | 967 } |
| 1032 m_context->bindAttribLocation(objectOrZero(program), index, name); | 968 m_context->bindAttribLocation(objectOrZero(program), index, name); |
| 1033 } | 969 } |
| 1034 | 970 |
| 1035 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL Object* object, bool& deleted) | 971 bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, W ebGLObject* object, bool& deleted) |
| 1036 { | 972 { |
| 1037 deleted = false; | 973 deleted = false; |
| 1038 if (isContextLost()) | 974 if (isContextLost()) |
| 1039 return false; | 975 return false; |
| 1040 if (object) { | 976 if (object) { |
| 1041 if (!object->validate(contextGroup(), this)) { | 977 if (!object->validate(contextGroup(), this)) { |
| 1042 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "object not from this context"); | 978 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "object not from this context"); |
| 1043 return false; | 979 return false; |
| 1044 } | 980 } |
| 1045 deleted = !object->object(); | 981 deleted = !object->object(); |
| 1046 } | 982 } |
| 1047 return true; | 983 return true; |
| 1048 } | 984 } |
| 1049 | 985 |
| 1050 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer) | 986 void WebGLRenderingContextBase::bindBuffer(GC3Denum target, WebGLBuffer* buffer) |
| 1051 { | 987 { |
| 1052 bool deleted; | 988 bool deleted; |
| 1053 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) | 989 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) |
| 1054 return; | 990 return; |
| 1055 if (deleted) | 991 if (deleted) |
| 1056 buffer = 0; | 992 buffer = 0; |
| 1057 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { | 993 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { |
| 1058 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b uffers can not be used with multiple targets"); | 994 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b uffers can not be used with multiple targets"); |
| 1059 return; | 995 return; |
| 1060 } | 996 } |
| 1061 if (target == GraphicsContext3D::ARRAY_BUFFER) | 997 if (target == GraphicsContext3D::ARRAY_BUFFER) { |
| 1062 m_boundArrayBuffer = buffer; | 998 m_boundArrayBuffer = buffer; |
| 1063 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) | 999 } else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) { |
| 1064 m_boundVertexArrayObject->setElementArrayBuffer(buffer); | 1000 m_boundVertexArrayObject->setElementArrayBuffer(buffer); |
| 1065 else { | 1001 } else { |
| 1066 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali d target"); | 1002 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali d target"); |
| 1067 return; | 1003 return; |
| 1068 } | 1004 } |
| 1069 | 1005 |
| 1070 m_context->bindBuffer(target, objectOrZero(buffer)); | 1006 m_context->bindBuffer(target, objectOrZero(buffer)); |
| 1071 if (buffer) | 1007 if (buffer) |
| 1072 buffer->setTarget(target); | 1008 buffer->setTarget(target); |
| 1073 } | 1009 } |
| 1074 | 1010 |
| 1075 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b uffer) | 1011 void WebGLRenderingContextBase::bindFramebuffer(GC3Denum target, WebGLFramebuffe r* buffer) |
| 1076 { | 1012 { |
| 1077 bool deleted; | 1013 bool deleted; |
| 1078 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1014 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1079 return; | 1015 return; |
| 1080 if (deleted) | 1016 if (deleted) |
| 1081 buffer = 0; | 1017 buffer = 0; |
| 1082 if (target != GraphicsContext3D::FRAMEBUFFER) { | 1018 if (target != GraphicsContext3D::FRAMEBUFFER) { |
| 1083 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i nvalid target"); | 1019 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i nvalid target"); |
| 1084 return; | 1020 return; |
| 1085 } | 1021 } |
| 1086 m_framebufferBinding = buffer; | 1022 m_framebufferBinding = buffer; |
| 1087 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ())); | 1023 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ())); |
| 1088 if (!m_framebufferBinding) { | 1024 if (!m_framebufferBinding) { |
| 1089 // Instead of binding fb 0, bind the drawing buffer. | 1025 // Instead of binding fb 0, bind the drawing buffer. |
| 1090 m_drawingBuffer->bind(); | 1026 m_drawingBuffer->bind(); |
| 1091 } else | 1027 } else { |
| 1092 m_context->bindFramebuffer(target, objectOrZero(buffer)); | 1028 m_context->bindFramebuffer(target, objectOrZero(buffer)); |
| 1029 } | |
| 1093 if (buffer) | 1030 if (buffer) |
| 1094 buffer->setHasEverBeenBound(); | 1031 buffer->setHasEverBeenBound(); |
| 1095 applyStencilTest(); | 1032 applyStencilTest(); |
| 1096 } | 1033 } |
| 1097 | 1034 |
| 1098 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer* renderBuffer) | 1035 void WebGLRenderingContextBase::bindRenderbuffer(GC3Denum target, WebGLRenderbuf fer* renderBuffer) |
| 1099 { | 1036 { |
| 1100 bool deleted; | 1037 bool deleted; |
| 1101 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1038 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
| 1102 return; | 1039 return; |
| 1103 if (deleted) | 1040 if (deleted) |
| 1104 renderBuffer = 0; | 1041 renderBuffer = 0; |
| 1105 if (target != GraphicsContext3D::RENDERBUFFER) { | 1042 if (target != GraphicsContext3D::RENDERBUFFER) { |
| 1106 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", " invalid target"); | 1043 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", " invalid target"); |
| 1107 return; | 1044 return; |
| 1108 } | 1045 } |
| 1109 m_renderbufferBinding = renderBuffer; | 1046 m_renderbufferBinding = renderBuffer; |
| 1110 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1047 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
| 1111 if (renderBuffer) | 1048 if (renderBuffer) |
| 1112 renderBuffer->setHasEverBeenBound(); | 1049 renderBuffer->setHasEverBeenBound(); |
| 1113 } | 1050 } |
| 1114 | 1051 |
| 1115 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture) | 1052 void WebGLRenderingContextBase::bindTexture(GC3Denum target, WebGLTexture* textu re) |
| 1116 { | 1053 { |
| 1117 bool deleted; | 1054 bool deleted; |
| 1118 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1055 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
| 1119 return; | 1056 return; |
| 1120 if (deleted) | 1057 if (deleted) |
| 1121 texture = 0; | 1058 texture = 0; |
| 1122 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1059 if (texture && texture->getTarget() && texture->getTarget() != target) { |
| 1123 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", " textures can not be used with multiple targets"); | 1060 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", " textures can not be used with multiple targets"); |
| 1124 return; | 1061 return; |
| 1125 } | 1062 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1154 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL | 1091 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL |
| 1155 // ES 2.0 doesn't expose this flag (a bug in the specification) and | 1092 // ES 2.0 doesn't expose this flag (a bug in the specification) and |
| 1156 // otherwise the application has no control over the seams in this | 1093 // otherwise the application has no control over the seams in this |
| 1157 // dimension. However, it appears that supporting this properly on all | 1094 // dimension. However, it appears that supporting this properly on all |
| 1158 // platforms is fairly involved (will require a HashMap from texture ID | 1095 // platforms is fairly involved (will require a HashMap from texture ID |
| 1159 // in all ports), and we have not had any complaints, so the logic has | 1096 // in all ports), and we have not had any complaints, so the logic has |
| 1160 // been removed. | 1097 // been removed. |
| 1161 | 1098 |
| 1162 } | 1099 } |
| 1163 | 1100 |
| 1164 void WebGLRenderingContext::blendColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat alpha) | 1101 void WebGLRenderingContextBase::blendColor(GC3Dfloat red, GC3Dfloat green, GC3Df loat blue, GC3Dfloat alpha) |
| 1165 { | 1102 { |
| 1166 if (isContextLost()) | 1103 if (isContextLost()) |
| 1167 return; | 1104 return; |
| 1168 m_context->blendColor(red, green, blue, alpha); | 1105 m_context->blendColor(red, green, blue, alpha); |
| 1169 } | 1106 } |
| 1170 | 1107 |
| 1171 void WebGLRenderingContext::blendEquation(GC3Denum mode) | 1108 void WebGLRenderingContextBase::blendEquation(GC3Denum mode) |
| 1172 { | 1109 { |
| 1173 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) | 1110 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) |
| 1174 return; | 1111 return; |
| 1175 m_context->blendEquation(mode); | 1112 m_context->blendEquation(mode); |
| 1176 } | 1113 } |
| 1177 | 1114 |
| 1178 void WebGLRenderingContext::blendEquationSeparate(GC3Denum modeRGB, GC3Denum mod eAlpha) | 1115 void WebGLRenderingContextBase::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) |
| 1179 { | 1116 { |
| 1180 if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeR GB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) | 1117 if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeR GB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) |
| 1181 return; | 1118 return; |
| 1182 m_context->blendEquationSeparate(modeRGB, modeAlpha); | 1119 m_context->blendEquationSeparate(modeRGB, modeAlpha); |
| 1183 } | 1120 } |
| 1184 | 1121 |
| 1185 | 1122 |
| 1186 void WebGLRenderingContext::blendFunc(GC3Denum sfactor, GC3Denum dfactor) | 1123 void WebGLRenderingContextBase::blendFunc(GC3Denum sfactor, GC3Denum dfactor) |
| 1187 { | 1124 { |
| 1188 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfact or)) | 1125 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfact or)) |
| 1189 return; | 1126 return; |
| 1190 m_context->blendFunc(sfactor, dfactor); | 1127 m_context->blendFunc(sfactor, dfactor); |
| 1191 } | 1128 } |
| 1192 | 1129 |
| 1193 void WebGLRenderingContext::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) | 1130 void WebGLRenderingContextBase::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstR GB, GC3Denum srcAlpha, GC3Denum dstAlpha) |
| 1194 { | 1131 { |
| 1195 // Note: Alpha does not have the same restrictions as RGB. | 1132 // Note: Alpha does not have the same restrictions as RGB. |
| 1196 if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB , dstRGB)) | 1133 if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB , dstRGB)) |
| 1197 return; | 1134 return; |
| 1198 m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); | 1135 m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); |
| 1199 } | 1136 } |
| 1200 | 1137 |
| 1201 void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum usage) | 1138 void WebGLRenderingContextBase::bufferData(GC3Denum target, long long size, GC3D enum usage) |
| 1202 { | 1139 { |
| 1203 if (isContextLost()) | 1140 if (isContextLost()) |
| 1204 return; | 1141 return; |
| 1205 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); | 1142 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); |
| 1206 if (!buffer) | 1143 if (!buffer) |
| 1207 return; | 1144 return; |
| 1208 if (size < 0) { | 1145 if (size < 0) { |
| 1209 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size < 0"); | 1146 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size < 0"); |
| 1210 return; | 1147 return; |
| 1211 } | 1148 } |
| 1212 if (!size) { | 1149 if (!size) { |
| 1213 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size == 0"); | 1150 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size == 0"); |
| 1214 return; | 1151 return; |
| 1215 } | 1152 } |
| 1216 | 1153 |
| 1217 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage); | 1154 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage); |
| 1218 } | 1155 } |
| 1219 | 1156 |
| 1220 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3De num usage) | 1157 void WebGLRenderingContextBase::bufferData(GC3Denum target, ArrayBuffer* data, G C3Denum usage) |
| 1221 { | 1158 { |
| 1222 if (isContextLost()) | 1159 if (isContextLost()) |
| 1223 return; | 1160 return; |
| 1224 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); | 1161 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); |
| 1225 if (!buffer) | 1162 if (!buffer) |
| 1226 return; | 1163 return; |
| 1227 if (!data) { | 1164 if (!data) { |
| 1228 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da ta"); | 1165 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da ta"); |
| 1229 return; | 1166 return; |
| 1230 } | 1167 } |
| 1231 m_context->bufferData(target, data->byteLength(), data->data(), usage); | 1168 m_context->bufferData(target, data->byteLength(), data->data(), usage); |
| 1232 } | 1169 } |
| 1233 | 1170 |
| 1234 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, G C3Denum usage) | 1171 void WebGLRenderingContextBase::bufferData(GC3Denum target, ArrayBufferView* dat a, GC3Denum usage) |
| 1235 { | 1172 { |
| 1236 if (isContextLost()) | 1173 if (isContextLost()) |
| 1237 return; | 1174 return; |
| 1238 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); | 1175 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); |
| 1239 if (!buffer) | 1176 if (!buffer) |
| 1240 return; | 1177 return; |
| 1241 if (!data) { | 1178 if (!data) { |
| 1242 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da ta"); | 1179 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da ta"); |
| 1243 return; | 1180 return; |
| 1244 } | 1181 } |
| 1245 | 1182 |
| 1246 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage ); | 1183 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage ); |
| 1247 } | 1184 } |
| 1248 | 1185 |
| 1249 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr ayBuffer* data) | 1186 void WebGLRenderingContextBase::bufferSubData(GC3Denum target, long long offset, ArrayBuffer* data) |
| 1250 { | 1187 { |
| 1251 if (isContextLost()) | 1188 if (isContextLost()) |
| 1252 return; | 1189 return; |
| 1253 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); | 1190 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); |
| 1254 if (!buffer) | 1191 if (!buffer) |
| 1255 return; | 1192 return; |
| 1256 if (offset < 0) { | 1193 if (offset < 0) { |
| 1257 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of fset < 0"); | 1194 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of fset < 0"); |
| 1258 return; | 1195 return; |
| 1259 } | 1196 } |
| 1260 if (!data) | 1197 if (!data) |
| 1261 return; | 1198 return; |
| 1262 | 1199 |
| 1263 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->data()); | 1200 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->data()); |
| 1264 } | 1201 } |
| 1265 | 1202 |
| 1266 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr ayBufferView* data) | 1203 void WebGLRenderingContextBase::bufferSubData(GC3Denum target, long long offset, ArrayBufferView* data) |
| 1267 { | 1204 { |
| 1268 if (isContextLost()) | 1205 if (isContextLost()) |
| 1269 return; | 1206 return; |
| 1270 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); | 1207 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); |
| 1271 if (!buffer) | 1208 if (!buffer) |
| 1272 return; | 1209 return; |
| 1273 if (offset < 0) { | 1210 if (offset < 0) { |
| 1274 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of fset < 0"); | 1211 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of fset < 0"); |
| 1275 return; | 1212 return; |
| 1276 } | 1213 } |
| 1277 if (!data) | 1214 if (!data) |
| 1278 return; | 1215 return; |
| 1279 | 1216 |
| 1280 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->baseAddress()); | 1217 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->baseAddress()); |
| 1281 } | 1218 } |
| 1282 | 1219 |
| 1283 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) | 1220 GC3Denum WebGLRenderingContextBase::checkFramebufferStatus(GC3Denum target) |
| 1284 { | 1221 { |
| 1285 if (isContextLost()) | 1222 if (isContextLost()) |
| 1286 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; | 1223 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; |
| 1287 if (target != GraphicsContext3D::FRAMEBUFFER) { | 1224 if (target != GraphicsContext3D::FRAMEBUFFER) { |
| 1288 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat us", "invalid target"); | 1225 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat us", "invalid target"); |
| 1289 return 0; | 1226 return 0; |
| 1290 } | 1227 } |
| 1291 if (!m_framebufferBinding || !m_framebufferBinding->object()) | 1228 if (!m_framebufferBinding || !m_framebufferBinding->object()) |
| 1292 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; | 1229 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; |
| 1293 const char* reason = "framebuffer incomplete"; | 1230 const char* reason = "framebuffer incomplete"; |
| 1294 GC3Denum result = m_framebufferBinding->checkStatus(&reason); | 1231 GC3Denum result = m_framebufferBinding->checkStatus(&reason); |
| 1295 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { | 1232 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { |
| 1296 emitGLWarning("checkFramebufferStatus", reason); | 1233 emitGLWarning("checkFramebufferStatus", reason); |
| 1297 return result; | 1234 return result; |
| 1298 } | 1235 } |
| 1299 result = m_context->checkFramebufferStatus(target); | 1236 result = m_context->checkFramebufferStatus(target); |
| 1300 return result; | 1237 return result; |
| 1301 } | 1238 } |
| 1302 | 1239 |
| 1303 void WebGLRenderingContext::clear(GC3Dbitfield mask) | 1240 void WebGLRenderingContextBase::clear(GC3Dbitfield mask) |
| 1304 { | 1241 { |
| 1305 if (isContextLost()) | 1242 if (isContextLost()) |
| 1306 return; | 1243 return; |
| 1307 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_ BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { | 1244 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_ BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { |
| 1308 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma sk"); | 1245 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma sk"); |
| 1309 return; | 1246 return; |
| 1310 } | 1247 } |
| 1311 const char* reason = "framebuffer incomplete"; | 1248 const char* reason = "framebuffer incomplete"; |
| 1312 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { | 1249 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { |
| 1313 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle ar", reason); | 1250 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle ar", reason); |
| 1314 return; | 1251 return; |
| 1315 } | 1252 } |
| 1316 if (!clearIfComposited(mask)) | 1253 if (!clearIfComposited(mask)) |
| 1317 m_context->clear(mask); | 1254 m_context->clear(mask); |
| 1318 markContextChanged(); | 1255 markContextChanged(); |
| 1319 } | 1256 } |
| 1320 | 1257 |
| 1321 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC 3Dfloat a) | 1258 void WebGLRenderingContextBase::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b , GC3Dfloat a) |
| 1322 { | 1259 { |
| 1323 if (isContextLost()) | 1260 if (isContextLost()) |
| 1324 return; | 1261 return; |
| 1325 if (std::isnan(r)) | 1262 if (std::isnan(r)) |
| 1326 r = 0; | 1263 r = 0; |
| 1327 if (std::isnan(g)) | 1264 if (std::isnan(g)) |
| 1328 g = 0; | 1265 g = 0; |
| 1329 if (std::isnan(b)) | 1266 if (std::isnan(b)) |
| 1330 b = 0; | 1267 b = 0; |
| 1331 if (std::isnan(a)) | 1268 if (std::isnan(a)) |
| 1332 a = 1; | 1269 a = 1; |
| 1333 m_clearColor[0] = r; | 1270 m_clearColor[0] = r; |
| 1334 m_clearColor[1] = g; | 1271 m_clearColor[1] = g; |
| 1335 m_clearColor[2] = b; | 1272 m_clearColor[2] = b; |
| 1336 m_clearColor[3] = a; | 1273 m_clearColor[3] = a; |
| 1337 m_context->clearColor(r, g, b, a); | 1274 m_context->clearColor(r, g, b, a); |
| 1338 } | 1275 } |
| 1339 | 1276 |
| 1340 void WebGLRenderingContext::clearDepth(GC3Dfloat depth) | 1277 void WebGLRenderingContextBase::clearDepth(GC3Dfloat depth) |
| 1341 { | 1278 { |
| 1342 if (isContextLost()) | 1279 if (isContextLost()) |
| 1343 return; | 1280 return; |
| 1344 m_clearDepth = depth; | 1281 m_clearDepth = depth; |
| 1345 m_context->clearDepth(depth); | 1282 m_context->clearDepth(depth); |
| 1346 } | 1283 } |
| 1347 | 1284 |
| 1348 void WebGLRenderingContext::clearStencil(GC3Dint s) | 1285 void WebGLRenderingContextBase::clearStencil(GC3Dint s) |
| 1349 { | 1286 { |
| 1350 if (isContextLost()) | 1287 if (isContextLost()) |
| 1351 return; | 1288 return; |
| 1352 m_clearStencil = s; | 1289 m_clearStencil = s; |
| 1353 m_context->clearStencil(s); | 1290 m_context->clearStencil(s); |
| 1354 } | 1291 } |
| 1355 | 1292 |
| 1356 void WebGLRenderingContext::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dbo olean blue, GC3Dboolean alpha) | 1293 void WebGLRenderingContextBase::colorMask(GC3Dboolean red, GC3Dboolean green, GC 3Dboolean blue, GC3Dboolean alpha) |
| 1357 { | 1294 { |
| 1358 if (isContextLost()) | 1295 if (isContextLost()) |
| 1359 return; | 1296 return; |
| 1360 m_colorMask[0] = red; | 1297 m_colorMask[0] = red; |
| 1361 m_colorMask[1] = green; | 1298 m_colorMask[1] = green; |
| 1362 m_colorMask[2] = blue; | 1299 m_colorMask[2] = blue; |
| 1363 m_colorMask[3] = alpha; | 1300 m_colorMask[3] = alpha; |
| 1364 m_context->colorMask(red, green, blue, alpha); | 1301 m_context->colorMask(red, green, blue, alpha); |
| 1365 } | 1302 } |
| 1366 | 1303 |
| 1367 void WebGLRenderingContext::compileShader(WebGLShader* shader) | 1304 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) |
| 1368 { | 1305 { |
| 1369 if (isContextLost() || !validateWebGLObject("compileShader", shader)) | 1306 if (isContextLost() || !validateWebGLObject("compileShader", shader)) |
| 1370 return; | 1307 return; |
| 1371 m_context->compileShader(objectOrZero(shader)); | 1308 m_context->compileShader(objectOrZero(shader)); |
| 1372 } | 1309 } |
| 1373 | 1310 |
| 1374 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, | 1311 void WebGLRenderingContextBase::compressedTexImage2D(GC3Denum target, GC3Dint le vel, GC3Denum internalformat, GC3Dsizei width, |
| 1375 GC3Dsizei height, GC3Dint borde r, ArrayBufferView* data) | 1312 GC3Dsizei height, GC3Dint border, ArrayBufferView* data) |
| 1376 { | 1313 { |
| 1377 if (isContextLost()) | 1314 if (isContextLost()) |
| 1378 return; | 1315 return; |
| 1379 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) | 1316 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) |
| 1380 return; | 1317 return; |
| 1381 | 1318 |
| 1382 if (!validateCompressedTexFormat(internalformat)) { | 1319 if (!validateCompressedTexFormat(internalformat)) { |
| 1383 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D ", "invalid internalformat"); | 1320 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D ", "invalid internalformat"); |
| 1384 return; | 1321 return; |
| 1385 } | 1322 } |
| 1386 if (border) { | 1323 if (border) { |
| 1387 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2 D", "border not 0"); | 1324 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2 D", "border not 0"); |
| 1388 return; | 1325 return; |
| 1389 } | 1326 } |
| 1390 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2 D, target, level, width, height, internalformat)) | 1327 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2 D, target, level, width, height, internalformat)) |
| 1391 return; | 1328 return; |
| 1392 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in ternalformat, data)) | 1329 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in ternalformat, data)) |
| 1393 return; | 1330 return; |
| 1394 | 1331 |
| 1395 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t rue); | 1332 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t rue); |
| 1396 if (!tex) | 1333 if (!tex) |
| 1397 return; | 1334 return; |
| 1398 if (!isGLES2NPOTStrict()) { | 1335 if (!isGLES2NPOTStrict()) { |
| 1399 if (level && WebGLTexture::isNPOT(width, height)) { | 1336 if (level && WebGLTexture::isNPOT(width, height)) { |
| 1400 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm age2D", "level > 0 not power of 2"); | 1337 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm age2D", "level > 0 not power of 2"); |
| 1401 return; | 1338 return; |
| 1402 } | 1339 } |
| 1403 } | 1340 } |
| 1404 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid th, height, | 1341 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid th, height, |
| 1405 border, data->byteLength(), data-> baseAddress()); | 1342 border, data->byteLength(), data->baseAddress()); |
| 1406 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); | 1343 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); |
| 1407 } | 1344 } |
| 1408 | 1345 |
| 1409 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev el, GC3Dint xoffset, GC3Dint yoffset, | 1346 void WebGLRenderingContextBase::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, |
| 1410 GC3Dsizei width, GC3Dsizei h eight, GC3Denum format, ArrayBufferView* data) | 1347 GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data) |
| 1411 { | 1348 { |
| 1412 if (isContextLost()) | 1349 if (isContextLost()) |
| 1413 return; | 1350 return; |
| 1414 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) | 1351 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) |
| 1415 return; | 1352 return; |
| 1416 if (!validateCompressedTexFormat(format)) { | 1353 if (!validateCompressedTexFormat(format)) { |
| 1417 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag e2D", "invalid format"); | 1354 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag e2D", "invalid format"); |
| 1418 return; | 1355 return; |
| 1419 } | 1356 } |
| 1420 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data)) | 1357 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data)) |
| 1421 return; | 1358 return; |
| 1422 | 1359 |
| 1423 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target , true); | 1360 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target , true); |
| 1424 if (!tex) | 1361 if (!tex) |
| 1425 return; | 1362 return; |
| 1426 | 1363 |
| 1427 if (format != tex->getInternalFormat(target, level)) { | 1364 if (format != tex->getInternalFormat(target, level)) { |
| 1428 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu bImage2D", "format does not match texture format"); | 1365 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu bImage2D", "format does not match texture format"); |
| 1429 return; | 1366 return; |
| 1430 } | 1367 } |
| 1431 | 1368 |
| 1432 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l evel, xoffset, yoffset, width, height, format, tex)) | 1369 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l evel, xoffset, yoffset, width, height, format, tex)) |
| 1433 return; | 1370 return; |
| 1434 | 1371 |
| 1435 graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset , | 1372 graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset , |
| 1436 width, height, format, data->by teLength(), data->baseAddress()); | 1373 width, height, format, data->byteLength(), data->baseAddress()); |
| 1437 } | 1374 } |
| 1438 | 1375 |
| 1439 bool WebGLRenderingContext::validateSettableTexFormat(const char* functionName, GC3Denum format) | 1376 bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa me, GC3Denum format) |
| 1440 { | 1377 { |
| 1441 if (GraphicsContext3D::getClearBitsByFormat(format) & (GraphicsContext3D::DE PTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { | 1378 if (GraphicsContext3D::getClearBitsByFormat(format) & (GraphicsContext3D::DE PTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { |
| 1442 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ormat can not be set, only rendered to"); | 1379 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ormat can not be set, only rendered to"); |
| 1443 return false; | 1380 return false; |
| 1444 } | 1381 } |
| 1445 return true; | 1382 return true; |
| 1446 } | 1383 } |
| 1447 | 1384 |
| 1448 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3 Dint border) | 1385 void WebGLRenderingContextBase::copyTexImage2D(GC3Denum target, GC3Dint level, G C3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) |
| 1449 { | 1386 { |
| 1450 if (isContextLost()) | 1387 if (isContextLost()) |
| 1451 return; | 1388 return; |
| 1452 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l evel, internalformat, width, height, border, internalformat, GraphicsContext3D:: UNSIGNED_BYTE)) | 1389 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l evel, internalformat, width, height, border, internalformat, GraphicsContext3D:: UNSIGNED_BYTE)) |
| 1453 return; | 1390 return; |
| 1454 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) | 1391 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) |
| 1455 return; | 1392 return; |
| 1456 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); | 1393 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); |
| 1457 if (!tex) | 1394 if (!tex) |
| 1458 return; | 1395 return; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1469 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexImage2D", reason); | 1406 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexImage2D", reason); |
| 1470 return; | 1407 return; |
| 1471 } | 1408 } |
| 1472 clearIfComposited(); | 1409 clearIfComposited(); |
| 1473 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); | 1410 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); |
| 1474 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height , border); | 1411 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height , border); |
| 1475 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. | 1412 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. |
| 1476 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); | 1413 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); |
| 1477 } | 1414 } |
| 1478 | 1415 |
| 1479 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) | 1416 void WebGLRenderingContextBase::copyTexSubImage2D(GC3Denum target, GC3Dint level , GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Ds izei height) |
| 1480 { | 1417 { |
| 1481 if (isContextLost()) | 1418 if (isContextLost()) |
| 1482 return; | 1419 return; |
| 1483 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1420 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
| 1484 return; | 1421 return; |
| 1485 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true ); | 1422 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true ); |
| 1486 if (!tex) | 1423 if (!tex) |
| 1487 return; | 1424 return; |
| 1488 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c opyTexSubImage2D", width, height)) | 1425 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c opyTexSubImage2D", width, height)) |
| 1489 return; | 1426 return; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1506 const char* reason = "framebuffer incomplete"; | 1443 const char* reason = "framebuffer incomplete"; |
| 1507 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { | 1444 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { |
| 1508 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexSubImage2D", reason); | 1445 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexSubImage2D", reason); |
| 1509 return; | 1446 return; |
| 1510 } | 1447 } |
| 1511 clearIfComposited(); | 1448 clearIfComposited(); |
| 1512 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); | 1449 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); |
| 1513 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h eight); | 1450 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h eight); |
| 1514 } | 1451 } |
| 1515 | 1452 |
| 1516 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() | 1453 PassRefPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() |
| 1517 { | 1454 { |
| 1518 if (isContextLost()) | 1455 if (isContextLost()) |
| 1519 return 0; | 1456 return 0; |
| 1520 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); | 1457 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); |
| 1521 addSharedObject(o.get()); | 1458 addSharedObject(o.get()); |
| 1522 return o; | 1459 return o; |
| 1523 } | 1460 } |
| 1524 | 1461 |
| 1525 PassRefPtr<WebGLFramebuffer> WebGLRenderingContext::createFramebuffer() | 1462 PassRefPtr<WebGLFramebuffer> WebGLRenderingContextBase::createFramebuffer() |
| 1526 { | 1463 { |
| 1527 if (isContextLost()) | 1464 if (isContextLost()) |
| 1528 return 0; | 1465 return 0; |
| 1529 RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); | 1466 RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); |
| 1530 addContextObject(o.get()); | 1467 addContextObject(o.get()); |
| 1531 return o; | 1468 return o; |
| 1532 } | 1469 } |
| 1533 | 1470 |
| 1534 PassRefPtr<WebGLTexture> WebGLRenderingContext::createTexture() | 1471 PassRefPtr<WebGLTexture> WebGLRenderingContextBase::createTexture() |
| 1535 { | 1472 { |
| 1536 if (isContextLost()) | 1473 if (isContextLost()) |
| 1537 return 0; | 1474 return 0; |
| 1538 RefPtr<WebGLTexture> o = WebGLTexture::create(this); | 1475 RefPtr<WebGLTexture> o = WebGLTexture::create(this); |
| 1539 addSharedObject(o.get()); | 1476 addSharedObject(o.get()); |
| 1540 return o; | 1477 return o; |
| 1541 } | 1478 } |
| 1542 | 1479 |
| 1543 PassRefPtr<WebGLProgram> WebGLRenderingContext::createProgram() | 1480 PassRefPtr<WebGLProgram> WebGLRenderingContextBase::createProgram() |
| 1544 { | 1481 { |
| 1545 if (isContextLost()) | 1482 if (isContextLost()) |
| 1546 return 0; | 1483 return 0; |
| 1547 RefPtr<WebGLProgram> o = WebGLProgram::create(this); | 1484 RefPtr<WebGLProgram> o = WebGLProgram::create(this); |
| 1548 addSharedObject(o.get()); | 1485 addSharedObject(o.get()); |
| 1549 return o; | 1486 return o; |
| 1550 } | 1487 } |
| 1551 | 1488 |
| 1552 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer() | 1489 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContextBase::createRenderbuffer() |
| 1553 { | 1490 { |
| 1554 if (isContextLost()) | 1491 if (isContextLost()) |
| 1555 return 0; | 1492 return 0; |
| 1556 RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); | 1493 RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); |
| 1557 addSharedObject(o.get()); | 1494 addSharedObject(o.get()); |
| 1558 return o; | 1495 return o; |
| 1559 } | 1496 } |
| 1560 | 1497 |
| 1561 WebGLRenderbuffer* WebGLRenderingContext::ensureEmulatedStencilBuffer(GC3Denum t arget, WebGLRenderbuffer* renderbuffer) | 1498 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GC3Den um target, WebGLRenderbuffer* renderbuffer) |
| 1562 { | 1499 { |
| 1563 if (isContextLost()) | 1500 if (isContextLost()) |
| 1564 return 0; | 1501 return 0; |
| 1565 if (!renderbuffer->emulatedStencilBuffer()) { | 1502 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1566 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1503 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1567 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS tencilBuffer())); | 1504 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS tencilBuffer())); |
| 1568 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g et())); | 1505 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g et())); |
| 1569 } | 1506 } |
| 1570 return renderbuffer->emulatedStencilBuffer(); | 1507 return renderbuffer->emulatedStencilBuffer(); |
| 1571 } | 1508 } |
| 1572 | 1509 |
| 1573 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GC3Denum type) | 1510 PassRefPtr<WebGLShader> WebGLRenderingContextBase::createShader(GC3Denum type) |
| 1574 { | 1511 { |
| 1575 if (isContextLost()) | 1512 if (isContextLost()) |
| 1576 return 0; | 1513 return 0; |
| 1577 if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::F RAGMENT_SHADER) { | 1514 if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::F RAGMENT_SHADER) { |
| 1578 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "inva lid shader type"); | 1515 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "inva lid shader type"); |
| 1579 return 0; | 1516 return 0; |
| 1580 } | 1517 } |
| 1581 | 1518 |
| 1582 RefPtr<WebGLShader> o = WebGLShader::create(this, type); | 1519 RefPtr<WebGLShader> o = WebGLShader::create(this, type); |
| 1583 addSharedObject(o.get()); | 1520 addSharedObject(o.get()); |
| 1584 return o; | 1521 return o; |
| 1585 } | 1522 } |
| 1586 | 1523 |
| 1587 void WebGLRenderingContext::cullFace(GC3Denum mode) | 1524 void WebGLRenderingContextBase::cullFace(GC3Denum mode) |
| 1588 { | 1525 { |
| 1589 if (isContextLost()) | 1526 if (isContextLost()) |
| 1590 return; | 1527 return; |
| 1591 switch (mode) { | 1528 switch (mode) { |
| 1592 case GraphicsContext3D::FRONT_AND_BACK: | 1529 case GraphicsContext3D::FRONT_AND_BACK: |
| 1593 case GraphicsContext3D::FRONT: | 1530 case GraphicsContext3D::FRONT: |
| 1594 case GraphicsContext3D::BACK: | 1531 case GraphicsContext3D::BACK: |
| 1595 break; | 1532 break; |
| 1596 default: | 1533 default: |
| 1597 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "cullFace", "invalid mode"); | 1534 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "cullFace", "invalid mode"); |
| 1598 return; | 1535 return; |
| 1599 } | 1536 } |
| 1600 m_context->cullFace(mode); | 1537 m_context->cullFace(mode); |
| 1601 } | 1538 } |
| 1602 | 1539 |
| 1603 bool WebGLRenderingContext::deleteObject(WebGLObject* object) | 1540 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) |
| 1604 { | 1541 { |
| 1605 if (isContextLost() || !object) | 1542 if (isContextLost() || !object) |
| 1606 return false; | 1543 return false; |
| 1607 if (!object->validate(contextGroup(), this)) { | 1544 if (!object->validate(contextGroup(), this)) { |
| 1608 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "objec t does not belong to this context"); | 1545 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "objec t does not belong to this context"); |
| 1609 return false; | 1546 return false; |
| 1610 } | 1547 } |
| 1611 if (object->object()) | 1548 if (object->object()) { |
| 1612 // We need to pass in context here because we want | 1549 // We need to pass in context here because we want |
| 1613 // things in this context unbound. | 1550 // things in this context unbound. |
| 1614 object->deleteObject(graphicsContext3D()); | 1551 object->deleteObject(graphicsContext3D()); |
| 1552 } | |
| 1615 return true; | 1553 return true; |
| 1616 } | 1554 } |
| 1617 | 1555 |
| 1618 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) | 1556 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) |
| 1619 { | 1557 { |
| 1620 if (!deleteObject(buffer)) | 1558 if (!deleteObject(buffer)) |
| 1621 return; | 1559 return; |
| 1622 if (m_boundArrayBuffer == buffer) | 1560 if (m_boundArrayBuffer == buffer) |
| 1623 m_boundArrayBuffer = 0; | 1561 m_boundArrayBuffer = 0; |
| 1624 | 1562 |
| 1625 m_boundVertexArrayObject->unbindBuffer(buffer); | 1563 m_boundVertexArrayObject->unbindBuffer(buffer); |
| 1626 } | 1564 } |
| 1627 | 1565 |
| 1628 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) | 1566 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
| 1629 { | 1567 { |
| 1630 if (!deleteObject(framebuffer)) | 1568 if (!deleteObject(framebuffer)) |
| 1631 return; | 1569 return; |
| 1632 if (framebuffer == m_framebufferBinding) { | 1570 if (framebuffer == m_framebufferBinding) { |
| 1633 m_framebufferBinding = 0; | 1571 m_framebufferBinding = 0; |
| 1634 m_drawingBuffer->setFramebufferBinding(0); | 1572 m_drawingBuffer->setFramebufferBinding(0); |
| 1635 // Have to call bindFramebuffer here to bind back to internal fbo. | 1573 // Have to call bindFramebuffer here to bind back to internal fbo. |
| 1636 m_drawingBuffer->bind(); | 1574 m_drawingBuffer->bind(); |
| 1637 } | 1575 } |
| 1638 } | 1576 } |
| 1639 | 1577 |
| 1640 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) | 1578 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) |
| 1641 { | 1579 { |
| 1642 deleteObject(program); | 1580 deleteObject(program); |
| 1643 // We don't reset m_currentProgram to 0 here because the deletion of the | 1581 // We don't reset m_currentProgram to 0 here because the deletion of the |
| 1644 // current program is delayed. | 1582 // current program is delayed. |
| 1645 } | 1583 } |
| 1646 | 1584 |
| 1647 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) | 1585 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er) |
| 1648 { | 1586 { |
| 1649 if (!deleteObject(renderbuffer)) | 1587 if (!deleteObject(renderbuffer)) |
| 1650 return; | 1588 return; |
| 1651 if (renderbuffer == m_renderbufferBinding) | 1589 if (renderbuffer == m_renderbufferBinding) |
| 1652 m_renderbufferBinding = 0; | 1590 m_renderbufferBinding = 0; |
| 1653 if (m_framebufferBinding) | 1591 if (m_framebufferBinding) |
| 1654 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer) ; | 1592 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer) ; |
| 1655 } | 1593 } |
| 1656 | 1594 |
| 1657 void WebGLRenderingContext::deleteShader(WebGLShader* shader) | 1595 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) |
| 1658 { | 1596 { |
| 1659 deleteObject(shader); | 1597 deleteObject(shader); |
| 1660 } | 1598 } |
| 1661 | 1599 |
| 1662 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) | 1600 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) |
| 1663 { | 1601 { |
| 1664 if (!deleteObject(texture)) | 1602 if (!deleteObject(texture)) |
| 1665 return; | 1603 return; |
| 1666 | 1604 |
| 1667 int maxBoundTextureIndex = -1; | 1605 int maxBoundTextureIndex = -1; |
| 1668 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { | 1606 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { |
| 1669 if (texture == m_textureUnits[i].m_texture2DBinding) { | 1607 if (texture == m_textureUnits[i].m_texture2DBinding) { |
| 1670 m_textureUnits[i].m_texture2DBinding = 0; | 1608 m_textureUnits[i].m_texture2DBinding = 0; |
| 1671 maxBoundTextureIndex = i; | 1609 maxBoundTextureIndex = i; |
| 1672 if (!i) | 1610 if (!i) |
| 1673 m_drawingBuffer->setTexture2DBinding(0); | 1611 m_drawingBuffer->setTexture2DBinding(0); |
| 1674 } | 1612 } |
| 1675 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { | 1613 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { |
| 1676 m_textureUnits[i].m_textureCubeMapBinding = 0; | 1614 m_textureUnits[i].m_textureCubeMapBinding = 0; |
| 1677 maxBoundTextureIndex = i; | 1615 maxBoundTextureIndex = i; |
| 1678 } | 1616 } |
| 1679 } | 1617 } |
| 1680 if (m_framebufferBinding) | 1618 if (m_framebufferBinding) |
| 1681 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); | 1619 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); |
| 1682 | 1620 |
| 1683 // If the deleted was bound to the the current maximum index, trace backward s to find the new max texture index | 1621 // If the deleted was bound to the the current maximum index, trace backward s to find the new max texture index |
| 1684 if (m_onePlusMaxNonDefaultTextureUnit == maxBoundTextureIndex + 1) { | 1622 if (m_onePlusMaxNonDefaultTextureUnit == maxBoundTextureIndex + 1) { |
| 1685 findNewMaxNonDefaultTextureUnit(); | 1623 findNewMaxNonDefaultTextureUnit(); |
| 1686 } | 1624 } |
| 1687 } | 1625 } |
| 1688 | 1626 |
| 1689 void WebGLRenderingContext::depthFunc(GC3Denum func) | 1627 void WebGLRenderingContextBase::depthFunc(GC3Denum func) |
| 1690 { | 1628 { |
| 1691 if (isContextLost()) | 1629 if (isContextLost()) |
| 1692 return; | 1630 return; |
| 1693 if (!validateStencilOrDepthFunc("depthFunc", func)) | 1631 if (!validateStencilOrDepthFunc("depthFunc", func)) |
| 1694 return; | 1632 return; |
| 1695 m_context->depthFunc(func); | 1633 m_context->depthFunc(func); |
| 1696 } | 1634 } |
| 1697 | 1635 |
| 1698 void WebGLRenderingContext::depthMask(GC3Dboolean flag) | 1636 void WebGLRenderingContextBase::depthMask(GC3Dboolean flag) |
| 1699 { | 1637 { |
| 1700 if (isContextLost()) | 1638 if (isContextLost()) |
| 1701 return; | 1639 return; |
| 1702 m_depthMask = flag; | 1640 m_depthMask = flag; |
| 1703 m_context->depthMask(flag); | 1641 m_context->depthMask(flag); |
| 1704 } | 1642 } |
| 1705 | 1643 |
| 1706 void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar) | 1644 void WebGLRenderingContextBase::depthRange(GC3Dfloat zNear, GC3Dfloat zFar) |
| 1707 { | 1645 { |
| 1708 if (isContextLost()) | 1646 if (isContextLost()) |
| 1709 return; | 1647 return; |
| 1710 if (zNear > zFar) { | 1648 if (zNear > zFar) { |
| 1711 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z Near > zFar"); | 1649 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z Near > zFar"); |
| 1712 return; | 1650 return; |
| 1713 } | 1651 } |
| 1714 m_context->depthRange(zNear, zFar); | 1652 m_context->depthRange(zNear, zFar); |
| 1715 } | 1653 } |
| 1716 | 1654 |
| 1717 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha der) | 1655 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* shader) |
| 1718 { | 1656 { |
| 1719 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) | 1657 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) |
| 1720 return; | 1658 return; |
| 1721 if (!program->detachShader(shader)) { | 1659 if (!program->detachShader(shader)) { |
| 1722 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached"); | 1660 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached"); |
| 1723 return; | 1661 return; |
| 1724 } | 1662 } |
| 1725 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); | 1663 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); |
| 1726 shader->onDetached(graphicsContext3D()); | 1664 shader->onDetached(graphicsContext3D()); |
| 1727 } | 1665 } |
| 1728 | 1666 |
| 1729 void WebGLRenderingContext::disable(GC3Denum cap) | 1667 void WebGLRenderingContextBase::disable(GC3Denum cap) |
| 1730 { | 1668 { |
| 1731 if (isContextLost() || !validateCapability("disable", cap)) | 1669 if (isContextLost() || !validateCapability("disable", cap)) |
| 1732 return; | 1670 return; |
| 1733 if (cap == GraphicsContext3D::STENCIL_TEST) { | 1671 if (cap == GraphicsContext3D::STENCIL_TEST) { |
| 1734 m_stencilEnabled = false; | 1672 m_stencilEnabled = false; |
| 1735 applyStencilTest(); | 1673 applyStencilTest(); |
| 1736 return; | 1674 return; |
| 1737 } | 1675 } |
| 1738 if (cap == GraphicsContext3D::SCISSOR_TEST) { | 1676 if (cap == GraphicsContext3D::SCISSOR_TEST) { |
| 1739 m_scissorEnabled = false; | 1677 m_scissorEnabled = false; |
| 1740 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1678 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); |
| 1741 } | 1679 } |
| 1742 m_context->disable(cap); | 1680 m_context->disable(cap); |
| 1743 } | 1681 } |
| 1744 | 1682 |
| 1745 void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index) | 1683 void WebGLRenderingContextBase::disableVertexAttribArray(GC3Duint index) |
| 1746 { | 1684 { |
| 1747 if (isContextLost()) | 1685 if (isContextLost()) |
| 1748 return; | 1686 return; |
| 1749 if (index >= m_maxVertexAttribs) { | 1687 if (index >= m_maxVertexAttribs) { |
| 1750 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttrib Array", "index out of range"); | 1688 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttrib Array", "index out of range"); |
| 1751 return; | 1689 return; |
| 1752 } | 1690 } |
| 1753 | 1691 |
| 1754 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); | 1692 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); |
| 1755 state.enabled = false; | 1693 state.enabled = false; |
| 1756 | 1694 |
| 1757 // If the disabled index is the current maximum, trace backwards to find the new max enabled attrib index | 1695 // If the disabled index is the current maximum, trace backwards to find the new max enabled attrib index |
| 1758 if (m_onePlusMaxEnabledAttribIndex == index + 1) { | 1696 if (m_onePlusMaxEnabledAttribIndex == index + 1) { |
| 1759 findNewMaxEnabledAttribIndex(); | 1697 findNewMaxEnabledAttribIndex(); |
| 1760 } | 1698 } |
| 1761 | 1699 |
| 1762 m_context->disableVertexAttribArray(index); | 1700 m_context->disableVertexAttribArray(index); |
| 1763 } | 1701 } |
| 1764 | 1702 |
| 1765 bool WebGLRenderingContext::validateRenderingState() | 1703 bool WebGLRenderingContextBase::validateRenderingState() |
| 1766 { | 1704 { |
| 1767 if (!m_currentProgram) | 1705 if (!m_currentProgram) |
| 1768 return false; | 1706 return false; |
| 1769 | 1707 |
| 1770 // Look in each enabled vertex attrib and check if they've been bound to a b uffer. | 1708 // Look in each enabled vertex attrib and check if they've been bound to a b uffer. |
| 1771 for (unsigned i = 0; i < m_onePlusMaxEnabledAttribIndex; ++i) { | 1709 for (unsigned i = 0; i < m_onePlusMaxEnabledAttribIndex; ++i) { |
| 1772 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i); | 1710 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i); |
| 1773 if (state.enabled | 1711 if (state.enabled |
| 1774 && (!state.bufferBinding || !state.bufferBinding->object())) | 1712 && (!state.bufferBinding || !state.bufferBinding->object())) |
| 1775 return false; | 1713 return false; |
| 1776 } | 1714 } |
| 1777 | 1715 |
| 1778 return true; | 1716 return true; |
| 1779 } | 1717 } |
| 1780 | 1718 |
| 1781 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO bject* object) | 1719 bool WebGLRenderingContextBase::validateWebGLObject(const char* functionName, We bGLObject* object) |
| 1782 { | 1720 { |
| 1783 if (!object || !object->object()) { | 1721 if (!object || !object->object()) { |
| 1784 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob ject or object deleted"); | 1722 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob ject or object deleted"); |
| 1785 return false; | 1723 return false; |
| 1786 } | 1724 } |
| 1787 if (!object->validate(contextGroup(), this)) { | 1725 if (!object->validate(contextGroup(), this)) { |
| 1788 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o bject does not belong to this context"); | 1726 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o bject does not belong to this context"); |
| 1789 return false; | 1727 return false; |
| 1790 } | 1728 } |
| 1791 return true; | 1729 return true; |
| 1792 } | 1730 } |
| 1793 | 1731 |
| 1794 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c ount) | 1732 void WebGLRenderingContextBase::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsiz ei count) |
| 1795 { | 1733 { |
| 1796 if (!validateDrawArrays("drawArrays", mode, first, count)) | 1734 if (!validateDrawArrays("drawArrays", mode, first, count)) |
| 1797 return; | 1735 return; |
| 1798 | 1736 |
| 1799 clearIfComposited(); | 1737 clearIfComposited(); |
| 1800 | 1738 |
| 1801 handleTextureCompleteness("drawArrays", true); | 1739 handleTextureCompleteness("drawArrays", true); |
| 1802 m_context->drawArrays(mode, first, count); | 1740 m_context->drawArrays(mode, first, count); |
| 1803 handleTextureCompleteness("drawArrays", false); | 1741 handleTextureCompleteness("drawArrays", false); |
| 1804 markContextChanged(); | 1742 markContextChanged(); |
| 1805 } | 1743 } |
| 1806 | 1744 |
| 1807 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denu m type, long long offset) | 1745 void WebGLRenderingContextBase::drawElements(GC3Denum mode, GC3Dsizei count, GC3 Denum type, long long offset) |
| 1808 { | 1746 { |
| 1809 if (!validateDrawElements("drawElements", mode, count, type, offset)) | 1747 if (!validateDrawElements("drawElements", mode, count, type, offset)) |
| 1810 return; | 1748 return; |
| 1811 | 1749 |
| 1812 clearIfComposited(); | 1750 clearIfComposited(); |
| 1813 | 1751 |
| 1814 handleTextureCompleteness("drawElements", true); | 1752 handleTextureCompleteness("drawElements", true); |
| 1815 m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset)); | 1753 m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset)); |
| 1816 handleTextureCompleteness("drawElements", false); | 1754 handleTextureCompleteness("drawElements", false); |
| 1817 markContextChanged(); | 1755 markContextChanged(); |
| 1818 } | 1756 } |
| 1819 | 1757 |
| 1820 void WebGLRenderingContext::drawArraysInstancedANGLE(GC3Denum mode, GC3Dint firs t, GC3Dsizei count, GC3Dsizei primcount) | 1758 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) |
| 1821 { | 1759 { |
| 1822 if (!validateDrawArrays("drawArraysInstancedANGLE", mode, first, count)) | 1760 if (!validateDrawArrays("drawArraysInstancedANGLE", mode, first, count)) |
| 1823 return; | 1761 return; |
| 1824 | 1762 |
| 1825 if (!validateDrawInstanced("drawArraysInstancedANGLE", primcount)) | 1763 if (!validateDrawInstanced("drawArraysInstancedANGLE", primcount)) |
| 1826 return; | 1764 return; |
| 1827 | 1765 |
| 1828 clearIfComposited(); | 1766 clearIfComposited(); |
| 1829 | 1767 |
| 1830 handleTextureCompleteness("drawArraysInstancedANGLE", true); | 1768 handleTextureCompleteness("drawArraysInstancedANGLE", true); |
| 1831 m_context->getExtensions()->drawArraysInstancedANGLE(mode, first, count, pri mcount); | 1769 m_context->getExtensions()->drawArraysInstancedANGLE(mode, first, count, pri mcount); |
| 1832 handleTextureCompleteness("drawArraysInstancedANGLE", false); | 1770 handleTextureCompleteness("drawArraysInstancedANGLE", false); |
| 1833 markContextChanged(); | 1771 markContextChanged(); |
| 1834 } | 1772 } |
| 1835 | 1773 |
| 1836 void WebGLRenderingContext::drawElementsInstancedANGLE(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) | 1774 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GC3Denum mode, GC3Dsi zei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) |
| 1837 { | 1775 { |
| 1838 if (!validateDrawElements("drawElementsInstancedANGLE", mode, count, type, o ffset)) | 1776 if (!validateDrawElements("drawElementsInstancedANGLE", mode, count, type, o ffset)) |
| 1839 return; | 1777 return; |
| 1840 | 1778 |
| 1841 if (!validateDrawInstanced("drawElementsInstancedANGLE", primcount)) | 1779 if (!validateDrawInstanced("drawElementsInstancedANGLE", primcount)) |
| 1842 return; | 1780 return; |
| 1843 | 1781 |
| 1844 clearIfComposited(); | 1782 clearIfComposited(); |
| 1845 | 1783 |
| 1846 handleTextureCompleteness("drawElementsInstancedANGLE", true); | 1784 handleTextureCompleteness("drawElementsInstancedANGLE", true); |
| 1847 m_context->getExtensions()->drawElementsInstancedANGLE(mode, count, type, st atic_cast<GC3Dintptr>(offset), primcount); | 1785 m_context->getExtensions()->drawElementsInstancedANGLE(mode, count, type, st atic_cast<GC3Dintptr>(offset), primcount); |
| 1848 handleTextureCompleteness("drawElementsInstancedANGLE", false); | 1786 handleTextureCompleteness("drawElementsInstancedANGLE", false); |
| 1849 markContextChanged(); | 1787 markContextChanged(); |
| 1850 } | 1788 } |
| 1851 | 1789 |
| 1852 void WebGLRenderingContext::enable(GC3Denum cap) | 1790 void WebGLRenderingContextBase::enable(GC3Denum cap) |
| 1853 { | 1791 { |
| 1854 if (isContextLost() || !validateCapability("enable", cap)) | 1792 if (isContextLost() || !validateCapability("enable", cap)) |
| 1855 return; | 1793 return; |
| 1856 if (cap == GraphicsContext3D::STENCIL_TEST) { | 1794 if (cap == GraphicsContext3D::STENCIL_TEST) { |
| 1857 m_stencilEnabled = true; | 1795 m_stencilEnabled = true; |
| 1858 applyStencilTest(); | 1796 applyStencilTest(); |
| 1859 return; | 1797 return; |
| 1860 } | 1798 } |
| 1861 if (cap == GraphicsContext3D::SCISSOR_TEST) { | 1799 if (cap == GraphicsContext3D::SCISSOR_TEST) { |
| 1862 m_scissorEnabled = true; | 1800 m_scissorEnabled = true; |
| 1863 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1801 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); |
| 1864 } | 1802 } |
| 1865 m_context->enable(cap); | 1803 m_context->enable(cap); |
| 1866 } | 1804 } |
| 1867 | 1805 |
| 1868 void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index) | 1806 void WebGLRenderingContextBase::enableVertexAttribArray(GC3Duint index) |
| 1869 { | 1807 { |
| 1870 if (isContextLost()) | 1808 if (isContextLost()) |
| 1871 return; | 1809 return; |
| 1872 if (index >= m_maxVertexAttribs) { | 1810 if (index >= m_maxVertexAttribs) { |
| 1873 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "enableVertexAttribA rray", "index out of range"); | 1811 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "enableVertexAttribA rray", "index out of range"); |
| 1874 return; | 1812 return; |
| 1875 } | 1813 } |
| 1876 | 1814 |
| 1877 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); | 1815 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); |
| 1878 state.enabled = true; | 1816 state.enabled = true; |
| 1879 | 1817 |
| 1880 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd ex); | 1818 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd ex); |
| 1881 | 1819 |
| 1882 m_context->enableVertexAttribArray(index); | 1820 m_context->enableVertexAttribArray(index); |
| 1883 } | 1821 } |
| 1884 | 1822 |
| 1885 void WebGLRenderingContext::finish() | 1823 void WebGLRenderingContextBase::finish() |
| 1886 { | 1824 { |
| 1887 if (isContextLost()) | 1825 if (isContextLost()) |
| 1888 return; | 1826 return; |
| 1889 m_context->flush(); // Intentionally a flush, not a finish. | 1827 m_context->flush(); // Intentionally a flush, not a finish. |
| 1890 } | 1828 } |
| 1891 | 1829 |
| 1892 void WebGLRenderingContext::flush() | 1830 void WebGLRenderingContextBase::flush() |
| 1893 { | 1831 { |
| 1894 if (isContextLost()) | 1832 if (isContextLost()) |
| 1895 return; | 1833 return; |
| 1896 m_context->flush(); | 1834 m_context->flush(); |
| 1897 } | 1835 } |
| 1898 | 1836 |
| 1899 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer) | 1837 void WebGLRenderingContextBase::framebufferRenderbuffer(GC3Denum target, GC3Denu m attachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer) |
| 1900 { | 1838 { |
| 1901 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) | 1839 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) |
| 1902 return; | 1840 return; |
| 1903 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { | 1841 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { |
| 1904 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf fer", "invalid target"); | 1842 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf fer", "invalid target"); |
| 1905 return; | 1843 return; |
| 1906 } | 1844 } |
| 1907 if (buffer && !buffer->validate(contextGroup(), this)) { | 1845 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 1908 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no buffer or buffer not from this context"); | 1846 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no buffer or buffer not from this context"); |
| 1909 return; | 1847 return; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1931 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI L_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 1869 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI L_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); |
| 1932 } | 1870 } |
| 1933 break; | 1871 break; |
| 1934 default: | 1872 default: |
| 1935 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject); | 1873 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject); |
| 1936 } | 1874 } |
| 1937 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); | 1875 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); |
| 1938 applyStencilTest(); | 1876 applyStencilTest(); |
| 1939 } | 1877 } |
| 1940 | 1878 |
| 1941 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level) | 1879 void WebGLRenderingContextBase::framebufferTexture2D(GC3Denum target, GC3Denum a ttachment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level) |
| 1942 { | 1880 { |
| 1943 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) | 1881 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) |
| 1944 return; | 1882 return; |
| 1945 if (level) { | 1883 if (level) { |
| 1946 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0"); | 1884 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0"); |
| 1947 return; | 1885 return; |
| 1948 } | 1886 } |
| 1949 if (texture && !texture->validate(contextGroup(), this)) { | 1887 if (texture && !texture->validate(contextGroup(), this)) { |
| 1950 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no texture or texture not from this context"); | 1888 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no texture or texture not from this context"); |
| 1951 return; | 1889 return; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1969 case GraphicsContext3D::STENCIL_ATTACHMENT: | 1907 case GraphicsContext3D::STENCIL_ATTACHMENT: |
| 1970 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); | 1908 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); |
| 1971 break; | 1909 break; |
| 1972 default: | 1910 default: |
| 1973 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); | 1911 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); |
| 1974 } | 1912 } |
| 1975 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); | 1913 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); |
| 1976 applyStencilTest(); | 1914 applyStencilTest(); |
| 1977 } | 1915 } |
| 1978 | 1916 |
| 1979 void WebGLRenderingContext::frontFace(GC3Denum mode) | 1917 void WebGLRenderingContextBase::frontFace(GC3Denum mode) |
| 1980 { | 1918 { |
| 1981 if (isContextLost()) | 1919 if (isContextLost()) |
| 1982 return; | 1920 return; |
| 1983 switch (mode) { | 1921 switch (mode) { |
| 1984 case GraphicsContext3D::CW: | 1922 case GraphicsContext3D::CW: |
| 1985 case GraphicsContext3D::CCW: | 1923 case GraphicsContext3D::CCW: |
| 1986 break; | 1924 break; |
| 1987 default: | 1925 default: |
| 1988 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "frontFace", "invalid mode"); | 1926 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "frontFace", "invalid mode"); |
| 1989 return; | 1927 return; |
| 1990 } | 1928 } |
| 1991 m_context->frontFace(mode); | 1929 m_context->frontFace(mode); |
| 1992 } | 1930 } |
| 1993 | 1931 |
| 1994 void WebGLRenderingContext::generateMipmap(GC3Denum target) | 1932 void WebGLRenderingContextBase::generateMipmap(GC3Denum target) |
| 1995 { | 1933 { |
| 1996 if (isContextLost()) | 1934 if (isContextLost()) |
| 1997 return; | 1935 return; |
| 1998 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); | 1936 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); |
| 1999 if (!tex) | 1937 if (!tex) |
| 2000 return; | 1938 return; |
| 2001 if (!tex->canGenerateMipmaps()) { | 1939 if (!tex->canGenerateMipmaps()) { |
| 2002 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap" , "level 0 not power of 2 or not all the same size"); | 1940 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap" , "level 0 not power of 2 or not all the same size"); |
| 2003 return; | 1941 return; |
| 2004 } | 1942 } |
| 2005 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ et, 0))) | 1943 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ et, 0))) |
| 2006 return; | 1944 return; |
| 2007 | 1945 |
| 2008 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN EAR | 1946 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN EAR |
| 2009 // on Mac. Remove the hack once this driver bug is fixed. | 1947 // on Mac. Remove the hack once this driver bug is fixed. |
| 2010 #if OS(MACOSX) | 1948 #if OS(MACOSX) |
| 2011 bool needToResetMinFilter = false; | 1949 bool needToResetMinFilter = false; |
| 2012 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { | 1950 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { |
| 2013 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST_MIPMAP_LINEAR); | 1951 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST_MIPMAP_LINEAR); |
| 2014 needToResetMinFilter = true; | 1952 needToResetMinFilter = true; |
| 2015 } | 1953 } |
| 2016 #endif | 1954 #endif |
| 2017 m_context->generateMipmap(target); | 1955 m_context->generateMipmap(target); |
| 2018 #if OS(MACOSX) | 1956 #if OS(MACOSX) |
| 2019 if (needToResetMinFilter) | 1957 if (needToResetMinFilter) |
| 2020 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, tex->getMinFilter()); | 1958 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, tex->getMinFilter()); |
| 2021 #endif | 1959 #endif |
| 2022 tex->generateMipmapLevelInfo(); | 1960 tex->generateMipmapLevelInfo(); |
| 2023 } | 1961 } |
| 2024 | 1962 |
| 2025 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index) | 1963 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg ram* program, GC3Duint index) |
| 2026 { | 1964 { |
| 2027 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 1965 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2028 return 0; | 1966 return 0; |
| 2029 ActiveInfo info; | 1967 ActiveInfo info; |
| 2030 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) | 1968 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) |
| 2031 return 0; | 1969 return 0; |
| 2032 return WebGLActiveInfo::create(info.name, info.type, info.size); | 1970 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2033 } | 1971 } |
| 2034 | 1972 |
| 2035 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram * program, GC3Duint index) | 1973 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLPro gram* program, GC3Duint index) |
| 2036 { | 1974 { |
| 2037 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 1975 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) |
| 2038 return 0; | 1976 return 0; |
| 2039 ActiveInfo info; | 1977 ActiveInfo info; |
| 2040 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) | 1978 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) |
| 2041 return 0; | 1979 return 0; |
| 2042 return WebGLActiveInfo::create(info.name, info.type, info.size); | 1980 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2043 } | 1981 } |
| 2044 | 1982 |
| 2045 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref Ptr<WebGLShader> >& shaderObjects) | 1983 bool WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program, Vector <RefPtr<WebGLShader> >& shaderObjects) |
| 2046 { | 1984 { |
| 2047 shaderObjects.clear(); | 1985 shaderObjects.clear(); |
| 2048 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 1986 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
| 2049 return false; | 1987 return false; |
| 2050 | 1988 |
| 2051 const GC3Denum shaderType[] = { | 1989 const GC3Denum shaderType[] = { |
| 2052 GraphicsContext3D::VERTEX_SHADER, | 1990 GraphicsContext3D::VERTEX_SHADER, |
| 2053 GraphicsContext3D::FRAGMENT_SHADER | 1991 GraphicsContext3D::FRAGMENT_SHADER |
| 2054 }; | 1992 }; |
| 2055 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { | 1993 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { |
| 2056 WebGLShader* shader = program->getAttachedShader(shaderType[i]); | 1994 WebGLShader* shader = program->getAttachedShader(shaderType[i]); |
| 2057 if (shader) | 1995 if (shader) |
| 2058 shaderObjects.append(shader); | 1996 shaderObjects.append(shader); |
| 2059 } | 1997 } |
| 2060 return true; | 1998 return true; |
| 2061 } | 1999 } |
| 2062 | 2000 |
| 2063 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St ring& name) | 2001 GC3Dint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program, cons t String& name) |
| 2064 { | 2002 { |
| 2065 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) | 2003 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) |
| 2066 return -1; | 2004 return -1; |
| 2067 if (!validateLocationLength("getAttribLocation", name)) | 2005 if (!validateLocationLength("getAttribLocation", name)) |
| 2068 return -1; | 2006 return -1; |
| 2069 if (!validateString("getAttribLocation", name)) | 2007 if (!validateString("getAttribLocation", name)) |
| 2070 return -1; | 2008 return -1; |
| 2071 if (isPrefixReserved(name)) | 2009 if (isPrefixReserved(name)) |
| 2072 return -1; | 2010 return -1; |
| 2073 if (!program->getLinkStatus()) { | 2011 if (!program->getLinkStatus()) { |
| 2074 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati on", "program not linked"); | 2012 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati on", "program not linked"); |
| 2075 return 0; | 2013 return 0; |
| 2076 } | 2014 } |
| 2077 return m_context->getAttribLocation(objectOrZero(program), name); | 2015 return m_context->getAttribLocation(objectOrZero(program), name); |
| 2078 } | 2016 } |
| 2079 | 2017 |
| 2080 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname) | 2018 WebGLGetInfo WebGLRenderingContextBase::getBufferParameter(GC3Denum target, GC3D enum pname) |
| 2081 { | 2019 { |
| 2082 if (isContextLost()) | 2020 if (isContextLost()) |
| 2083 return WebGLGetInfo(); | 2021 return WebGLGetInfo(); |
| 2084 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D ::ELEMENT_ARRAY_BUFFER) { | 2022 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D ::ELEMENT_ARRAY_BUFFER) { |
| 2085 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid target"); | 2023 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid target"); |
| 2086 return WebGLGetInfo(); | 2024 return WebGLGetInfo(); |
| 2087 } | 2025 } |
| 2088 | 2026 |
| 2089 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B UFFER_USAGE) { | 2027 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B UFFER_USAGE) { |
| 2090 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid parameter name"); | 2028 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid parameter name"); |
| 2091 return WebGLGetInfo(); | 2029 return WebGLGetInfo(); |
| 2092 } | 2030 } |
| 2093 | 2031 |
| 2094 GC3Dint value = 0; | 2032 GC3Dint value = 0; |
| 2095 m_context->getBufferParameteriv(target, pname, &value); | 2033 m_context->getBufferParameteriv(target, pname, &value); |
| 2096 if (pname == GraphicsContext3D::BUFFER_SIZE) | 2034 if (pname == GraphicsContext3D::BUFFER_SIZE) |
| 2097 return WebGLGetInfo(value); | 2035 return WebGLGetInfo(value); |
| 2098 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2036 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2099 } | 2037 } |
| 2100 | 2038 |
| 2101 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() | 2039 PassRefPtr<WebGLContextAttributes> WebGLRenderingContextBase::getContextAttribut es() |
| 2102 { | 2040 { |
| 2103 if (isContextLost()) | 2041 if (isContextLost()) |
| 2104 return 0; | 2042 return 0; |
| 2105 // We always need to return a new WebGLContextAttributes object to | 2043 // We always need to return a new WebGLContextAttributes object to |
| 2106 // prevent the user from mutating any cached version. | 2044 // prevent the user from mutating any cached version. |
| 2107 | 2045 |
| 2108 // Also, we need to enforce requested values of "false" for depth | 2046 // Also, we need to enforce requested values of "false" for depth |
| 2109 // and stencil, regardless of the properties of the underlying | 2047 // and stencil, regardless of the properties of the underlying |
| 2110 // GraphicsContext3D or DrawingBuffer. | 2048 // GraphicsContext3D or DrawingBuffer. |
| 2111 RefPtr<WebGLContextAttributes> attributes = WebGLContextAttributes::create(m _context->getContextAttributes()); | 2049 RefPtr<WebGLContextAttributes> attributes = WebGLContextAttributes::create(m _context->getContextAttributes()); |
| 2112 if (!m_attributes.depth) | 2050 if (!m_attributes.depth) |
| 2113 attributes->setDepth(false); | 2051 attributes->setDepth(false); |
| 2114 if (!m_attributes.stencil) | 2052 if (!m_attributes.stencil) |
| 2115 attributes->setStencil(false); | 2053 attributes->setStencil(false); |
| 2116 // The DrawingBuffer obtains its parameters from GraphicsContext3D::getConte xtAttributes(), | 2054 // The DrawingBuffer obtains its parameters from GraphicsContext3D::getConte xtAttributes(), |
| 2117 // but it makes its own determination of whether multisampling is supported. | 2055 // but it makes its own determination of whether multisampling is supported. |
| 2118 attributes->setAntialias(m_drawingBuffer->multisample()); | 2056 attributes->setAntialias(m_drawingBuffer->multisample()); |
| 2119 return attributes.release(); | 2057 return attributes.release(); |
| 2120 } | 2058 } |
| 2121 | 2059 |
| 2122 GC3Denum WebGLRenderingContext::getError() | 2060 GC3Denum WebGLRenderingContextBase::getError() |
| 2123 { | 2061 { |
| 2124 if (lost_context_errors_.size()) { | 2062 if (m_lostContextErrors.size()) { |
| 2125 GC3Denum err = lost_context_errors_.first(); | 2063 GC3Denum err = m_lostContextErrors.first(); |
| 2126 lost_context_errors_.remove(0); | 2064 m_lostContextErrors.remove(0); |
| 2127 return err; | 2065 return err; |
| 2128 } | 2066 } |
| 2129 | 2067 |
| 2130 if (isContextLost()) | 2068 if (isContextLost()) |
| 2131 return GraphicsContext3D::NO_ERROR; | 2069 return GraphicsContext3D::NO_ERROR; |
| 2132 | 2070 |
| 2133 return m_context->getError(); | 2071 return m_context->getError(); |
| 2134 } | 2072 } |
| 2135 | 2073 |
| 2136 bool WebGLRenderingContext::ExtensionTracker::matchesNameWithPrefixes(const Stri ng& name) const | 2074 bool WebGLRenderingContextBase::ExtensionTracker::matchesNameWithPrefixes(const String& name) const |
| 2137 { | 2075 { |
| 2138 static const char* unprefixed[] = { "", 0, }; | 2076 static const char* unprefixed[] = { "", 0, }; |
| 2139 | 2077 |
| 2140 const char** prefixes = m_prefixes ? m_prefixes : unprefixed; | 2078 const char** prefixes = m_prefixes ? m_prefixes : unprefixed; |
| 2141 for (; *prefixes; ++prefixes) { | 2079 for (; *prefixes; ++prefixes) { |
| 2142 String prefixedName = String(*prefixes) + getExtensionName(); | 2080 String prefixedName = String(*prefixes) + getExtensionName(); |
| 2143 if (equalIgnoringCase(prefixedName, name)) { | 2081 if (equalIgnoringCase(prefixedName, name)) { |
| 2144 return true; | 2082 return true; |
| 2145 } | 2083 } |
| 2146 } | 2084 } |
| 2147 return false; | 2085 return false; |
| 2148 } | 2086 } |
| 2149 | 2087 |
| 2150 PassRefPtr<WebGLExtension> WebGLRenderingContext::getExtension(const String& nam e) | 2088 PassRefPtr<WebGLExtension> WebGLRenderingContextBase::getExtension(const String& name) |
| 2151 { | 2089 { |
| 2152 if (isContextLost()) | 2090 if (isContextLost()) |
| 2153 return 0; | 2091 return 0; |
| 2154 | 2092 |
| 2155 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2093 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2156 ExtensionTracker* tracker = m_extensions[i]; | 2094 ExtensionTracker* tracker = m_extensions[i]; |
| 2157 if (tracker->matchesNameWithPrefixes(name)) { | 2095 if (tracker->matchesNameWithPrefixes(name)) { |
| 2158 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) | 2096 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) |
| 2159 return 0; | 2097 return 0; |
| 2160 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtens ionsEnabled()) | 2098 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtens ionsEnabled()) |
| 2161 return 0; | 2099 return 0; |
| 2162 if (!tracker->supported(this)) | 2100 if (!tracker->supported(this)) |
| 2163 return 0; | 2101 return 0; |
| 2164 return tracker->getExtension(this); | 2102 |
| 2103 RefPtr<WebGLExtension> extension = tracker->getExtension(this); | |
| 2104 if (extension) | |
| 2105 m_extensionEnabled[extension->getName()] = true; | |
| 2106 return extension.release(); | |
| 2165 } | 2107 } |
| 2166 } | 2108 } |
| 2167 | 2109 |
| 2168 return 0; | 2110 return 0; |
| 2169 } | 2111 } |
| 2170 | 2112 |
| 2171 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum t arget, GC3Denum attachment, GC3Denum pname) | 2113 WebGLGetInfo WebGLRenderingContextBase::getFramebufferAttachmentParameter(GC3Den um target, GC3Denum attachment, GC3Denum pname) |
| 2172 { | 2114 { |
| 2173 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) | 2115 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) |
| 2174 return WebGLGetInfo(); | 2116 return WebGLGetInfo(); |
| 2175 | 2117 |
| 2176 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2118 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 2177 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getFramebufferA ttachmentParameter", "no framebuffer bound"); | 2119 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getFramebufferA ttachmentParameter", "no framebuffer bound"); |
| 2178 return WebGLGetInfo(); | 2120 return WebGLGetInfo(); |
| 2179 } | 2121 } |
| 2180 | 2122 |
| 2181 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); | 2123 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2212 return WebGLGetInfo(GraphicsContext3D::RENDERBUFFER); | 2154 return WebGLGetInfo(GraphicsContext3D::RENDERBUFFER); |
| 2213 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2155 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2214 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR enderbuffer*>(object))); | 2156 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR enderbuffer*>(object))); |
| 2215 default: | 2157 default: |
| 2216 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAt tachmentParameter", "invalid parameter name for renderbuffer attachment"); | 2158 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAt tachmentParameter", "invalid parameter name for renderbuffer attachment"); |
| 2217 return WebGLGetInfo(); | 2159 return WebGLGetInfo(); |
| 2218 } | 2160 } |
| 2219 } | 2161 } |
| 2220 } | 2162 } |
| 2221 | 2163 |
| 2222 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname) | 2164 WebGLGetInfo WebGLRenderingContextBase::getParameter(GC3Denum pname) |
| 2223 { | 2165 { |
| 2224 if (isContextLost()) | 2166 if (isContextLost()) |
| 2225 return WebGLGetInfo(); | 2167 return WebGLGetInfo(); |
| 2226 const int intZero = 0; | 2168 const int intZero = 0; |
| 2227 switch (pname) { | 2169 switch (pname) { |
| 2228 case GraphicsContext3D::ACTIVE_TEXTURE: | 2170 case GraphicsContext3D::ACTIVE_TEXTURE: |
| 2229 return getUnsignedIntParameter(pname); | 2171 return getUnsignedIntParameter(pname); |
| 2230 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: | 2172 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: |
| 2231 return getWebGLFloatArrayParameter(pname); | 2173 return getWebGLFloatArrayParameter(pname); |
| 2232 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: | 2174 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2396 return WebGLGetInfo(m_unpackPremultiplyAlpha); | 2338 return WebGLGetInfo(m_unpackPremultiplyAlpha); |
| 2397 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: | 2339 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: |
| 2398 return WebGLGetInfo(m_unpackColorspaceConversion); | 2340 return WebGLGetInfo(m_unpackColorspaceConversion); |
| 2399 case GraphicsContext3D::VENDOR: | 2341 case GraphicsContext3D::VENDOR: |
| 2400 return WebGLGetInfo(String("WebKit")); | 2342 return WebGLGetInfo(String("WebKit")); |
| 2401 case GraphicsContext3D::VERSION: | 2343 case GraphicsContext3D::VERSION: |
| 2402 return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GraphicsContext 3D::VERSION) + ")"); | 2344 return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GraphicsContext 3D::VERSION) + ")"); |
| 2403 case GraphicsContext3D::VIEWPORT: | 2345 case GraphicsContext3D::VIEWPORT: |
| 2404 return getWebGLIntArrayParameter(pname); | 2346 return getWebGLIntArrayParameter(pname); |
| 2405 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives | 2347 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives |
| 2406 if (m_oesStandardDerivatives) | 2348 if (extensionEnabled(OESStandardDerivativesName)) |
| 2407 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT IVE_HINT_OES); | 2349 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT IVE_HINT_OES); |
| 2408 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, OES_standard_derivatives not enabled"); | 2350 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, OES_standard_derivatives not enabled"); |
| 2409 return WebGLGetInfo(); | 2351 return WebGLGetInfo(); |
| 2410 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: | 2352 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: |
| 2411 if (m_webglDebugRendererInfo) | 2353 if (extensionEnabled(WebGLDebugRendererInfoName)) |
| 2412 return WebGLGetInfo(m_context->getString(GraphicsContext3D::RENDERER )); | 2354 return WebGLGetInfo(m_context->getString(GraphicsContext3D::RENDERER )); |
| 2413 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_debug_renderer_info not enabled"); | 2355 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_debug_renderer_info not enabled"); |
| 2414 return WebGLGetInfo(); | 2356 return WebGLGetInfo(); |
| 2415 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: | 2357 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: |
| 2416 if (m_webglDebugRendererInfo) | 2358 if (extensionEnabled(WebGLDebugRendererInfoName)) |
| 2417 return WebGLGetInfo(m_context->getString(GraphicsContext3D::VENDOR)) ; | 2359 return WebGLGetInfo(m_context->getString(GraphicsContext3D::VENDOR)) ; |
| 2418 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_debug_renderer_info not enabled"); | 2360 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_debug_renderer_info not enabled"); |
| 2419 return WebGLGetInfo(); | 2361 return WebGLGetInfo(); |
| 2420 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object | 2362 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object |
| 2421 if (m_oesVertexArrayObject) { | 2363 if (extensionEnabled(OESVertexArrayObjectName)) { |
| 2422 if (!m_boundVertexArrayObject->isDefaultObject()) | 2364 if (!m_boundVertexArrayObject->isDefaultObject()) |
| 2423 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject)); | 2365 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject)); |
| 2424 return WebGLGetInfo(); | 2366 return WebGLGetInfo(); |
| 2425 } | 2367 } |
| 2426 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, OES_vertex_array_object not enabled"); | 2368 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, OES_vertex_array_object not enabled"); |
| 2427 return WebGLGetInfo(); | 2369 return WebGLGetInfo(); |
| 2428 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani sotropic | 2370 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani sotropic |
| 2429 if (m_extTextureFilterAnisotropic) | 2371 if (extensionEnabled(EXTTextureFilterAnisotropicName)) |
| 2430 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR OPY_EXT); | 2372 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR OPY_EXT); |
| 2431 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, EXT_texture_filter_anisotropic not enabled"); | 2373 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, EXT_texture_filter_anisotropic not enabled"); |
| 2432 return WebGLGetInfo(); | 2374 return WebGLGetInfo(); |
| 2433 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN | 2375 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN |
| 2434 if (m_webglDrawBuffers) | 2376 if (extensionEnabled(WebGLDrawBuffersName)) |
| 2435 return WebGLGetInfo(getMaxColorAttachments()); | 2377 return WebGLGetInfo(getMaxColorAttachments()); |
| 2436 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_draw_buffers not enabled"); | 2378 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_draw_buffers not enabled"); |
| 2437 return WebGLGetInfo(); | 2379 return WebGLGetInfo(); |
| 2438 case Extensions3D::MAX_DRAW_BUFFERS_EXT: | 2380 case Extensions3D::MAX_DRAW_BUFFERS_EXT: |
| 2439 if (m_webglDrawBuffers) | 2381 if (extensionEnabled(WebGLDrawBuffersName)) |
| 2440 return WebGLGetInfo(getMaxDrawBuffers()); | 2382 return WebGLGetInfo(getMaxDrawBuffers()); |
| 2441 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_draw_buffers not enabled"); | 2383 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_draw_buffers not enabled"); |
| 2442 return WebGLGetInfo(); | 2384 return WebGLGetInfo(); |
| 2443 default: | 2385 default: |
| 2444 if (m_webglDrawBuffers | 2386 if (extensionEnabled(WebGLDrawBuffersName) |
| 2445 && pname >= Extensions3D::DRAW_BUFFER0_EXT | 2387 && pname >= Extensions3D::DRAW_BUFFER0_EXT |
| 2446 && pname < static_cast<GC3Denum>(Extensions3D::DRAW_BUFFER0_EXT + ge tMaxDrawBuffers())) { | 2388 && pname < static_cast<GC3Denum>(Extensions3D::DRAW_BUFFER0_EXT + ge tMaxDrawBuffers())) { |
| 2447 GC3Dint value = GraphicsContext3D::NONE; | 2389 GC3Dint value = GraphicsContext3D::NONE; |
| 2448 if (m_framebufferBinding) | 2390 if (m_framebufferBinding) |
| 2449 value = m_framebufferBinding->getDrawBuffer(pname); | 2391 value = m_framebufferBinding->getDrawBuffer(pname); |
| 2450 else // emulated backbuffer | 2392 else // emulated backbuffer |
| 2451 value = m_backDrawBuffer; | 2393 value = m_backDrawBuffer; |
| 2452 return WebGLGetInfo(value); | 2394 return WebGLGetInfo(value); |
| 2453 } | 2395 } |
| 2454 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name"); | 2396 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name"); |
| 2455 return WebGLGetInfo(); | 2397 return WebGLGetInfo(); |
| 2456 } | 2398 } |
| 2457 } | 2399 } |
| 2458 | 2400 |
| 2459 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G C3Denum pname) | 2401 WebGLGetInfo WebGLRenderingContextBase::getProgramParameter(WebGLProgram* progra m, GC3Denum pname) |
| 2460 { | 2402 { |
| 2461 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) | 2403 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) |
| 2462 return WebGLGetInfo(); | 2404 return WebGLGetInfo(); |
| 2463 | 2405 |
| 2464 GC3Dint value = 0; | 2406 GC3Dint value = 0; |
| 2465 switch (pname) { | 2407 switch (pname) { |
| 2466 case GraphicsContext3D::DELETE_STATUS: | 2408 case GraphicsContext3D::DELETE_STATUS: |
| 2467 return WebGLGetInfo(program->isDeleted()); | 2409 return WebGLGetInfo(program->isDeleted()); |
| 2468 case GraphicsContext3D::VALIDATE_STATUS: | 2410 case GraphicsContext3D::VALIDATE_STATUS: |
| 2469 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2411 m_context->getProgramiv(objectOrZero(program), pname, &value); |
| 2470 return WebGLGetInfo(static_cast<bool>(value)); | 2412 return WebGLGetInfo(static_cast<bool>(value)); |
| 2471 case GraphicsContext3D::LINK_STATUS: | 2413 case GraphicsContext3D::LINK_STATUS: |
| 2472 return WebGLGetInfo(program->getLinkStatus()); | 2414 return WebGLGetInfo(program->getLinkStatus()); |
| 2473 case GraphicsContext3D::ATTACHED_SHADERS: | 2415 case GraphicsContext3D::ATTACHED_SHADERS: |
| 2474 case GraphicsContext3D::ACTIVE_ATTRIBUTES: | 2416 case GraphicsContext3D::ACTIVE_ATTRIBUTES: |
| 2475 case GraphicsContext3D::ACTIVE_UNIFORMS: | 2417 case GraphicsContext3D::ACTIVE_UNIFORMS: |
| 2476 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2418 m_context->getProgramiv(objectOrZero(program), pname, &value); |
| 2477 return WebGLGetInfo(value); | 2419 return WebGLGetInfo(value); |
| 2478 default: | 2420 default: |
| 2479 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter" , "invalid parameter name"); | 2421 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter" , "invalid parameter name"); |
| 2480 return WebGLGetInfo(); | 2422 return WebGLGetInfo(); |
| 2481 } | 2423 } |
| 2482 } | 2424 } |
| 2483 | 2425 |
| 2484 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program) | 2426 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) |
| 2485 { | 2427 { |
| 2486 if (isContextLost()) | 2428 if (isContextLost()) |
| 2487 return String(); | 2429 return String(); |
| 2488 if (!validateWebGLObject("getProgramInfoLog", program)) | 2430 if (!validateWebGLObject("getProgramInfoLog", program)) |
| 2489 return ""; | 2431 return ""; |
| 2490 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); | 2432 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); |
| 2491 } | 2433 } |
| 2492 | 2434 |
| 2493 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC 3Denum pname) | 2435 WebGLGetInfo WebGLRenderingContextBase::getRenderbufferParameter(GC3Denum target , GC3Denum pname) |
| 2494 { | 2436 { |
| 2495 if (isContextLost()) | 2437 if (isContextLost()) |
| 2496 return WebGLGetInfo(); | 2438 return WebGLGetInfo(); |
| 2497 if (target != GraphicsContext3D::RENDERBUFFER) { | 2439 if (target != GraphicsContext3D::RENDERBUFFER) { |
| 2498 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid target"); | 2440 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid target"); |
| 2499 return WebGLGetInfo(); | 2441 return WebGLGetInfo(); |
| 2500 } | 2442 } |
| 2501 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 2443 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
| 2502 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer Parameter", "no renderbuffer bound"); | 2444 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer Parameter", "no renderbuffer bound"); |
| 2503 return WebGLGetInfo(); | 2445 return WebGLGetInfo(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2524 } | 2466 } |
| 2525 return WebGLGetInfo(value); | 2467 return WebGLGetInfo(value); |
| 2526 case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT: | 2468 case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT: |
| 2527 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); | 2469 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); |
| 2528 default: | 2470 default: |
| 2529 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid parameter name"); | 2471 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid parameter name"); |
| 2530 return WebGLGetInfo(); | 2472 return WebGLGetInfo(); |
| 2531 } | 2473 } |
| 2532 } | 2474 } |
| 2533 | 2475 |
| 2534 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D enum pname) | 2476 WebGLGetInfo WebGLRenderingContextBase::getShaderParameter(WebGLShader* shader, GC3Denum pname) |
| 2535 { | 2477 { |
| 2536 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) | 2478 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) |
| 2537 return WebGLGetInfo(); | 2479 return WebGLGetInfo(); |
| 2538 GC3Dint value = 0; | 2480 GC3Dint value = 0; |
| 2539 switch (pname) { | 2481 switch (pname) { |
| 2540 case GraphicsContext3D::DELETE_STATUS: | 2482 case GraphicsContext3D::DELETE_STATUS: |
| 2541 return WebGLGetInfo(shader->isDeleted()); | 2483 return WebGLGetInfo(shader->isDeleted()); |
| 2542 case GraphicsContext3D::COMPILE_STATUS: | 2484 case GraphicsContext3D::COMPILE_STATUS: |
| 2543 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2485 m_context->getShaderiv(objectOrZero(shader), pname, &value); |
| 2544 return WebGLGetInfo(static_cast<bool>(value)); | 2486 return WebGLGetInfo(static_cast<bool>(value)); |
| 2545 case GraphicsContext3D::SHADER_TYPE: | 2487 case GraphicsContext3D::SHADER_TYPE: |
| 2546 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2488 m_context->getShaderiv(objectOrZero(shader), pname, &value); |
| 2547 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2489 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2548 default: | 2490 default: |
| 2549 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name"); | 2491 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name"); |
| 2550 return WebGLGetInfo(); | 2492 return WebGLGetInfo(); |
| 2551 } | 2493 } |
| 2552 } | 2494 } |
| 2553 | 2495 |
| 2554 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader) | 2496 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) |
| 2555 { | 2497 { |
| 2556 if (isContextLost()) | 2498 if (isContextLost()) |
| 2557 return String(); | 2499 return String(); |
| 2558 if (!validateWebGLObject("getShaderInfoLog", shader)) | 2500 if (!validateWebGLObject("getShaderInfoLog", shader)) |
| 2559 return ""; | 2501 return ""; |
| 2560 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); | 2502 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); |
| 2561 } | 2503 } |
| 2562 | 2504 |
| 2563 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision Format(GC3Denum shaderType, GC3Denum precisionType) | 2505 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::getShaderPreci sionFormat(GC3Denum shaderType, GC3Denum precisionType) |
| 2564 { | 2506 { |
| 2565 if (isContextLost()) | 2507 if (isContextLost()) |
| 2566 return 0; | 2508 return 0; |
| 2567 switch (shaderType) { | 2509 switch (shaderType) { |
| 2568 case GraphicsContext3D::VERTEX_SHADER: | 2510 case GraphicsContext3D::VERTEX_SHADER: |
| 2569 case GraphicsContext3D::FRAGMENT_SHADER: | 2511 case GraphicsContext3D::FRAGMENT_SHADER: |
| 2570 break; | 2512 break; |
| 2571 default: | 2513 default: |
| 2572 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo rmat", "invalid shader type"); | 2514 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo rmat", "invalid shader type"); |
| 2573 return 0; | 2515 return 0; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2584 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo rmat", "invalid precision type"); | 2526 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo rmat", "invalid precision type"); |
| 2585 return 0; | 2527 return 0; |
| 2586 } | 2528 } |
| 2587 | 2529 |
| 2588 GC3Dint range[2] = {0, 0}; | 2530 GC3Dint range[2] = {0, 0}; |
| 2589 GC3Dint precision = 0; | 2531 GC3Dint precision = 0; |
| 2590 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci sion); | 2532 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci sion); |
| 2591 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 2533 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); |
| 2592 } | 2534 } |
| 2593 | 2535 |
| 2594 String WebGLRenderingContext::getShaderSource(WebGLShader* shader) | 2536 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) |
| 2595 { | 2537 { |
| 2596 if (isContextLost()) | 2538 if (isContextLost()) |
| 2597 return String(); | 2539 return String(); |
| 2598 if (!validateWebGLObject("getShaderSource", shader)) | 2540 if (!validateWebGLObject("getShaderSource", shader)) |
| 2599 return ""; | 2541 return ""; |
| 2600 return ensureNotNull(shader->getSource()); | 2542 return ensureNotNull(shader->getSource()); |
| 2601 } | 2543 } |
| 2602 | 2544 |
| 2603 Vector<String> WebGLRenderingContext::getSupportedExtensions() | 2545 Vector<String> WebGLRenderingContextBase::getSupportedExtensions() |
| 2604 { | 2546 { |
| 2605 Vector<String> result; | 2547 Vector<String> result; |
| 2606 if (isContextLost()) | 2548 if (isContextLost()) |
| 2607 return result; | 2549 return result; |
| 2608 | 2550 |
| 2609 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2551 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2610 ExtensionTracker* tracker = m_extensions[i]; | 2552 ExtensionTracker* tracker = m_extensions[i]; |
| 2611 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) | 2553 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) |
| 2612 continue; | 2554 continue; |
| 2613 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtensions Enabled()) | 2555 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtensions Enabled()) |
| 2614 continue; | 2556 continue; |
| 2615 if (tracker->supported(this)) | 2557 if (tracker->supported(this)) |
| 2616 result.append(String(tracker->getPrefixed() ? "WEBKIT_" : "") + tra cker->getExtensionName()); | 2558 result.append(String(tracker->getPrefixed() ? "WEBKIT_" : "") + tra cker->getExtensionName()); |
| 2617 } | 2559 } |
| 2618 | 2560 |
| 2619 return result; | 2561 return result; |
| 2620 } | 2562 } |
| 2621 | 2563 |
| 2622 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn ame) | 2564 WebGLGetInfo WebGLRenderingContextBase::getTexParameter(GC3Denum target, GC3Denu m pname) |
| 2623 { | 2565 { |
| 2624 if (isContextLost()) | 2566 if (isContextLost()) |
| 2625 return WebGLGetInfo(); | 2567 return WebGLGetInfo(); |
| 2626 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ; | 2568 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ; |
| 2627 if (!tex) | 2569 if (!tex) |
| 2628 return WebGLGetInfo(); | 2570 return WebGLGetInfo(); |
| 2629 GC3Dint value = 0; | 2571 GC3Dint value = 0; |
| 2630 switch (pname) { | 2572 switch (pname) { |
| 2631 case GraphicsContext3D::TEXTURE_MAG_FILTER: | 2573 case GraphicsContext3D::TEXTURE_MAG_FILTER: |
| 2632 case GraphicsContext3D::TEXTURE_MIN_FILTER: | 2574 case GraphicsContext3D::TEXTURE_MIN_FILTER: |
| 2633 case GraphicsContext3D::TEXTURE_WRAP_S: | 2575 case GraphicsContext3D::TEXTURE_WRAP_S: |
| 2634 case GraphicsContext3D::TEXTURE_WRAP_T: | 2576 case GraphicsContext3D::TEXTURE_WRAP_T: |
| 2635 m_context->getTexParameteriv(target, pname, &value); | 2577 m_context->getTexParameteriv(target, pname, &value); |
| 2636 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2578 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2637 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic | 2579 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic |
| 2638 if (m_extTextureFilterAnisotropic) { | 2580 if (extensionEnabled(EXTTextureFilterAnisotropicName)) { |
| 2639 m_context->getTexParameteriv(target, pname, &value); | 2581 m_context->getTexParameteriv(target, pname, &value); |
| 2640 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2582 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2641 } | 2583 } |
| 2642 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); | 2584 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); |
| 2643 return WebGLGetInfo(); | 2585 return WebGLGetInfo(); |
| 2644 default: | 2586 default: |
| 2645 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name"); | 2587 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name"); |
| 2646 return WebGLGetInfo(); | 2588 return WebGLGetInfo(); |
| 2647 } | 2589 } |
| 2648 } | 2590 } |
| 2649 | 2591 |
| 2650 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG LUniformLocation* uniformLocation) | 2592 WebGLGetInfo WebGLRenderingContextBase::getUniform(WebGLProgram* program, const WebGLUniformLocation* uniformLocation) |
| 2651 { | 2593 { |
| 2652 if (isContextLost() || !validateWebGLObject("getUniform", program)) | 2594 if (isContextLost() || !validateWebGLObject("getUniform", program)) |
| 2653 return WebGLGetInfo(); | 2595 return WebGLGetInfo(); |
| 2654 if (!uniformLocation || uniformLocation->program() != program) { | 2596 if (!uniformLocation || uniformLocation->program() != program) { |
| 2655 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n o uniformlocation or not valid for this program"); | 2597 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n o uniformlocation or not valid for this program"); |
| 2656 return WebGLGetInfo(); | 2598 return WebGLGetInfo(); |
| 2657 } | 2599 } |
| 2658 GC3Dint location = uniformLocation->location(); | 2600 GC3Dint location = uniformLocation->location(); |
| 2659 | 2601 |
| 2660 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it | 2602 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2673 if (info.size > 1 && index >= 1) { | 2615 if (info.size > 1 && index >= 1) { |
| 2674 name.append('['); | 2616 name.append('['); |
| 2675 name.append(String::number(index)); | 2617 name.append(String::number(index)); |
| 2676 name.append(']'); | 2618 name.append(']'); |
| 2677 } | 2619 } |
| 2678 // Now need to look this up by name again to find its location | 2620 // Now need to look this up by name again to find its location |
| 2679 GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), n ame); | 2621 GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), n ame); |
| 2680 if (loc == location) { | 2622 if (loc == location) { |
| 2681 // Found it. Use the type in the ActiveInfo to determine the ret urn type. | 2623 // Found it. Use the type in the ActiveInfo to determine the ret urn type. |
| 2682 GC3Denum baseType; | 2624 GC3Denum baseType; |
| 2683 unsigned int length; | 2625 unsigned length; |
| 2684 switch (info.type) { | 2626 switch (info.type) { |
| 2685 case GraphicsContext3D::BOOL: | 2627 case GraphicsContext3D::BOOL: |
| 2686 baseType = GraphicsContext3D::BOOL; | 2628 baseType = GraphicsContext3D::BOOL; |
| 2687 length = 1; | 2629 length = 1; |
| 2688 break; | 2630 break; |
| 2689 case GraphicsContext3D::BOOL_VEC2: | 2631 case GraphicsContext3D::BOOL_VEC2: |
| 2690 baseType = GraphicsContext3D::BOOL; | 2632 baseType = GraphicsContext3D::BOOL; |
| 2691 length = 2; | 2633 length = 2; |
| 2692 break; | 2634 break; |
| 2693 case GraphicsContext3D::BOOL_VEC3: | 2635 case GraphicsContext3D::BOOL_VEC3: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2782 notImplemented(); | 2724 notImplemented(); |
| 2783 } | 2725 } |
| 2784 } | 2726 } |
| 2785 } | 2727 } |
| 2786 } | 2728 } |
| 2787 // If we get here, something went wrong in our unfortunately complex logic a bove | 2729 // If we get here, something went wrong in our unfortunately complex logic a bove |
| 2788 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e rror"); | 2730 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e rror"); |
| 2789 return WebGLGetInfo(); | 2731 return WebGLGetInfo(); |
| 2790 } | 2732 } |
| 2791 | 2733 |
| 2792 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL Program* program, const String& name) | 2734 PassRefPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUniformLocation(W ebGLProgram* program, const String& name) |
| 2793 { | 2735 { |
| 2794 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) | 2736 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) |
| 2795 return 0; | 2737 return 0; |
| 2796 if (!validateLocationLength("getUniformLocation", name)) | 2738 if (!validateLocationLength("getUniformLocation", name)) |
| 2797 return 0; | 2739 return 0; |
| 2798 if (!validateString("getUniformLocation", name)) | 2740 if (!validateString("getUniformLocation", name)) |
| 2799 return 0; | 2741 return 0; |
| 2800 if (isPrefixReserved(name)) | 2742 if (isPrefixReserved(name)) |
| 2801 return 0; | 2743 return 0; |
| 2802 if (!program->getLinkStatus()) { | 2744 if (!program->getLinkStatus()) { |
| 2803 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat ion", "program not linked"); | 2745 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat ion", "program not linked"); |
| 2804 return 0; | 2746 return 0; |
| 2805 } | 2747 } |
| 2806 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program ), name); | 2748 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program ), name); |
| 2807 if (uniformLocation == -1) | 2749 if (uniformLocation == -1) |
| 2808 return 0; | 2750 return 0; |
| 2809 return WebGLUniformLocation::create(program, uniformLocation); | 2751 return WebGLUniformLocation::create(program, uniformLocation); |
| 2810 } | 2752 } |
| 2811 | 2753 |
| 2812 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna me) | 2754 WebGLGetInfo WebGLRenderingContextBase::getVertexAttrib(GC3Duint index, GC3Denum pname) |
| 2813 { | 2755 { |
| 2814 if (isContextLost()) | 2756 if (isContextLost()) |
| 2815 return WebGLGetInfo(); | 2757 return WebGLGetInfo(); |
| 2816 if (index >= m_maxVertexAttribs) { | 2758 if (index >= m_maxVertexAttribs) { |
| 2817 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", " index out of range"); | 2759 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", " index out of range"); |
| 2818 return WebGLGetInfo(); | 2760 return WebGLGetInfo(); |
| 2819 } | 2761 } |
| 2820 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); | 2762 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); |
| 2821 | 2763 |
| 2822 if (m_angleInstancedArrays && pname == Extensions3D::VERTEX_ATTRIB_ARRAY_DIV ISOR_ANGLE) | 2764 if (extensionEnabled(ANGLEInstancedArraysName) && pname == Extensions3D::VER TEX_ATTRIB_ARRAY_DIVISOR_ANGLE) |
| 2823 return WebGLGetInfo(state.divisor); | 2765 return WebGLGetInfo(state.divisor); |
| 2824 | 2766 |
| 2825 switch (pname) { | 2767 switch (pname) { |
| 2826 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: | 2768 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 2827 if (!state.bufferBinding || !state.bufferBinding->object()) | 2769 if (!state.bufferBinding || !state.bufferBinding->object()) |
| 2828 return WebGLGetInfo(); | 2770 return WebGLGetInfo(); |
| 2829 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); | 2771 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); |
| 2830 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_ENABLED: | 2772 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_ENABLED: |
| 2831 return WebGLGetInfo(state.enabled); | 2773 return WebGLGetInfo(state.enabled); |
| 2832 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_NORMALIZED: | 2774 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 2833 return WebGLGetInfo(state.normalized); | 2775 return WebGLGetInfo(state.normalized); |
| 2834 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_SIZE: | 2776 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_SIZE: |
| 2835 return WebGLGetInfo(state.size); | 2777 return WebGLGetInfo(state.size); |
| 2836 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_STRIDE: | 2778 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_STRIDE: |
| 2837 return WebGLGetInfo(state.originalStride); | 2779 return WebGLGetInfo(state.originalStride); |
| 2838 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_TYPE: | 2780 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_TYPE: |
| 2839 return WebGLGetInfo(state.type); | 2781 return WebGLGetInfo(state.type); |
| 2840 case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: | 2782 case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: |
| 2841 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].valu e, 4)); | 2783 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].valu e, 4)); |
| 2842 default: | 2784 default: |
| 2843 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttrib", "i nvalid parameter name"); | 2785 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttrib", "i nvalid parameter name"); |
| 2844 return WebGLGetInfo(); | 2786 return WebGLGetInfo(); |
| 2845 } | 2787 } |
| 2846 } | 2788 } |
| 2847 | 2789 |
| 2848 long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname) | 2790 long long WebGLRenderingContextBase::getVertexAttribOffset(GC3Duint index, GC3De num pname) |
| 2849 { | 2791 { |
| 2850 if (isContextLost()) | 2792 if (isContextLost()) |
| 2851 return 0; | 2793 return 0; |
| 2852 if (pname != GraphicsContext3D::VERTEX_ATTRIB_ARRAY_POINTER) { | 2794 if (pname != GraphicsContext3D::VERTEX_ATTRIB_ARRAY_POINTER) { |
| 2853 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttribOffse t", "invalid parameter name"); | 2795 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttribOffse t", "invalid parameter name"); |
| 2854 return 0; | 2796 return 0; |
| 2855 } | 2797 } |
| 2856 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); | 2798 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); |
| 2857 return static_cast<long long>(result); | 2799 return static_cast<long long>(result); |
| 2858 } | 2800 } |
| 2859 | 2801 |
| 2860 void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode) | 2802 void WebGLRenderingContextBase::hint(GC3Denum target, GC3Denum mode) |
| 2861 { | 2803 { |
| 2862 if (isContextLost()) | 2804 if (isContextLost()) |
| 2863 return; | 2805 return; |
| 2864 bool isValid = false; | 2806 bool isValid = false; |
| 2865 switch (target) { | 2807 switch (target) { |
| 2866 case GraphicsContext3D::GENERATE_MIPMAP_HINT: | 2808 case GraphicsContext3D::GENERATE_MIPMAP_HINT: |
| 2867 isValid = true; | 2809 isValid = true; |
| 2868 break; | 2810 break; |
| 2869 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives | 2811 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives |
| 2870 if (m_oesStandardDerivatives) | 2812 if (extensionEnabled(OESStandardDerivativesName)) |
| 2871 isValid = true; | 2813 isValid = true; |
| 2872 break; | 2814 break; |
| 2873 } | 2815 } |
| 2874 if (!isValid) { | 2816 if (!isValid) { |
| 2875 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "hint", "invalid targ et"); | 2817 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "hint", "invalid targ et"); |
| 2876 return; | 2818 return; |
| 2877 } | 2819 } |
| 2878 m_context->hint(target, mode); | 2820 m_context->hint(target, mode); |
| 2879 } | 2821 } |
| 2880 | 2822 |
| 2881 GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) | 2823 GC3Dboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) |
| 2882 { | 2824 { |
| 2883 if (!buffer || isContextLost()) | 2825 if (!buffer || isContextLost()) |
| 2884 return 0; | 2826 return 0; |
| 2885 | 2827 |
| 2886 if (!buffer->hasEverBeenBound()) | 2828 if (!buffer->hasEverBeenBound()) |
| 2887 return 0; | 2829 return 0; |
| 2888 | 2830 |
| 2889 return m_context->isBuffer(buffer->object()); | 2831 return m_context->isBuffer(buffer->object()); |
| 2890 } | 2832 } |
| 2891 | 2833 |
| 2892 bool WebGLRenderingContext::isContextLost() | 2834 bool WebGLRenderingContextBase::isContextLost() |
| 2893 { | 2835 { |
| 2894 return m_contextLost; | 2836 return m_contextLost; |
| 2895 } | 2837 } |
| 2896 | 2838 |
| 2897 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) | 2839 GC3Dboolean WebGLRenderingContextBase::isEnabled(GC3Denum cap) |
| 2898 { | 2840 { |
| 2899 if (isContextLost() || !validateCapability("isEnabled", cap)) | 2841 if (isContextLost() || !validateCapability("isEnabled", cap)) |
| 2900 return 0; | 2842 return 0; |
| 2901 if (cap == GraphicsContext3D::STENCIL_TEST) | 2843 if (cap == GraphicsContext3D::STENCIL_TEST) |
| 2902 return m_stencilEnabled; | 2844 return m_stencilEnabled; |
| 2903 return m_context->isEnabled(cap); | 2845 return m_context->isEnabled(cap); |
| 2904 } | 2846 } |
| 2905 | 2847 |
| 2906 GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) | 2848 GC3Dboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuff er) |
| 2907 { | 2849 { |
| 2908 if (!framebuffer || isContextLost()) | 2850 if (!framebuffer || isContextLost()) |
| 2909 return 0; | 2851 return 0; |
| 2910 | 2852 |
| 2911 if (!framebuffer->hasEverBeenBound()) | 2853 if (!framebuffer->hasEverBeenBound()) |
| 2912 return 0; | 2854 return 0; |
| 2913 | 2855 |
| 2914 return m_context->isFramebuffer(framebuffer->object()); | 2856 return m_context->isFramebuffer(framebuffer->object()); |
| 2915 } | 2857 } |
| 2916 | 2858 |
| 2917 GC3Dboolean WebGLRenderingContext::isProgram(WebGLProgram* program) | 2859 GC3Dboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) |
| 2918 { | 2860 { |
| 2919 if (!program || isContextLost()) | 2861 if (!program || isContextLost()) |
| 2920 return 0; | 2862 return 0; |
| 2921 | 2863 |
| 2922 return m_context->isProgram(program->object()); | 2864 return m_context->isProgram(program->object()); |
| 2923 } | 2865 } |
| 2924 | 2866 |
| 2925 GC3Dboolean WebGLRenderingContext::isRenderbuffer(WebGLRenderbuffer* renderbuffe r) | 2867 GC3Dboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderb uffer) |
| 2926 { | 2868 { |
| 2927 if (!renderbuffer || isContextLost()) | 2869 if (!renderbuffer || isContextLost()) |
| 2928 return 0; | 2870 return 0; |
| 2929 | 2871 |
| 2930 if (!renderbuffer->hasEverBeenBound()) | 2872 if (!renderbuffer->hasEverBeenBound()) |
| 2931 return 0; | 2873 return 0; |
| 2932 | 2874 |
| 2933 return m_context->isRenderbuffer(renderbuffer->object()); | 2875 return m_context->isRenderbuffer(renderbuffer->object()); |
| 2934 } | 2876 } |
| 2935 | 2877 |
| 2936 GC3Dboolean WebGLRenderingContext::isShader(WebGLShader* shader) | 2878 GC3Dboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) |
| 2937 { | 2879 { |
| 2938 if (!shader || isContextLost()) | 2880 if (!shader || isContextLost()) |
| 2939 return 0; | 2881 return 0; |
| 2940 | 2882 |
| 2941 return m_context->isShader(shader->object()); | 2883 return m_context->isShader(shader->object()); |
| 2942 } | 2884 } |
| 2943 | 2885 |
| 2944 GC3Dboolean WebGLRenderingContext::isTexture(WebGLTexture* texture) | 2886 GC3Dboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) |
| 2945 { | 2887 { |
| 2946 if (!texture || isContextLost()) | 2888 if (!texture || isContextLost()) |
| 2947 return 0; | 2889 return 0; |
| 2948 | 2890 |
| 2949 if (!texture->hasEverBeenBound()) | 2891 if (!texture->hasEverBeenBound()) |
| 2950 return 0; | 2892 return 0; |
| 2951 | 2893 |
| 2952 return m_context->isTexture(texture->object()); | 2894 return m_context->isTexture(texture->object()); |
| 2953 } | 2895 } |
| 2954 | 2896 |
| 2955 void WebGLRenderingContext::lineWidth(GC3Dfloat width) | 2897 void WebGLRenderingContextBase::lineWidth(GC3Dfloat width) |
| 2956 { | 2898 { |
| 2957 if (isContextLost()) | 2899 if (isContextLost()) |
| 2958 return; | 2900 return; |
| 2959 m_context->lineWidth(width); | 2901 m_context->lineWidth(width); |
| 2960 } | 2902 } |
| 2961 | 2903 |
| 2962 void WebGLRenderingContext::linkProgram(WebGLProgram* program) | 2904 void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) |
| 2963 { | 2905 { |
| 2964 if (isContextLost() || !validateWebGLObject("linkProgram", program)) | 2906 if (isContextLost() || !validateWebGLObject("linkProgram", program)) |
| 2965 return; | 2907 return; |
| 2966 | 2908 |
| 2967 m_context->linkProgram(objectOrZero(program)); | 2909 m_context->linkProgram(objectOrZero(program)); |
| 2968 program->increaseLinkCount(); | 2910 program->increaseLinkCount(); |
| 2969 } | 2911 } |
| 2970 | 2912 |
| 2971 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) | 2913 void WebGLRenderingContextBase::pixelStorei(GC3Denum pname, GC3Dint param) |
| 2972 { | 2914 { |
| 2973 if (isContextLost()) | 2915 if (isContextLost()) |
| 2974 return; | 2916 return; |
| 2975 switch (pname) { | 2917 switch (pname) { |
| 2976 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: | 2918 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: |
| 2977 m_unpackFlipY = param; | 2919 m_unpackFlipY = param; |
| 2978 break; | 2920 break; |
| 2979 case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: | 2921 case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: |
| 2980 m_unpackPremultiplyAlpha = param; | 2922 m_unpackPremultiplyAlpha = param; |
| 2981 break; | 2923 break; |
| 2982 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: | 2924 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: |
| 2983 if (param == GraphicsContext3D::BROWSER_DEFAULT_WEBGL || param == Graphi csContext3D::NONE) | 2925 if (param == GraphicsContext3D::BROWSER_DEFAULT_WEBGL || param == Graphi csContext3D::NONE) { |
| 2984 m_unpackColorspaceConversion = static_cast<GC3Denum>(param); | 2926 m_unpackColorspaceConversion = static_cast<GC3Denum>(param); |
| 2985 else { | 2927 } else { |
| 2986 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", " invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); | 2928 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", " invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); |
| 2987 return; | 2929 return; |
| 2988 } | 2930 } |
| 2989 break; | 2931 break; |
| 2990 case GraphicsContext3D::PACK_ALIGNMENT: | 2932 case GraphicsContext3D::PACK_ALIGNMENT: |
| 2991 case GraphicsContext3D::UNPACK_ALIGNMENT: | 2933 case GraphicsContext3D::UNPACK_ALIGNMENT: |
| 2992 if (param == 1 || param == 2 || param == 4 || param == 8) { | 2934 if (param == 1 || param == 2 || param == 4 || param == 8) { |
| 2993 if (pname == GraphicsContext3D::PACK_ALIGNMENT) | 2935 if (pname == GraphicsContext3D::PACK_ALIGNMENT) |
| 2994 m_packAlignment = param; | 2936 m_packAlignment = param; |
| 2995 else // GraphicsContext3D::UNPACK_ALIGNMENT: | 2937 else // GraphicsContext3D::UNPACK_ALIGNMENT: |
| 2996 m_unpackAlignment = param; | 2938 m_unpackAlignment = param; |
| 2997 m_context->pixelStorei(pname, param); | 2939 m_context->pixelStorei(pname, param); |
| 2998 } else { | 2940 } else { |
| 2999 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", " invalid parameter for alignment"); | 2941 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", " invalid parameter for alignment"); |
| 3000 return; | 2942 return; |
| 3001 } | 2943 } |
| 3002 break; | 2944 break; |
| 3003 default: | 2945 default: |
| 3004 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "pixelStorei", "inval id parameter name"); | 2946 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "pixelStorei", "inval id parameter name"); |
| 3005 return; | 2947 return; |
| 3006 } | 2948 } |
| 3007 } | 2949 } |
| 3008 | 2950 |
| 3009 void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units) | 2951 void WebGLRenderingContextBase::polygonOffset(GC3Dfloat factor, GC3Dfloat units) |
| 3010 { | 2952 { |
| 3011 if (isContextLost()) | 2953 if (isContextLost()) |
| 3012 return; | 2954 return; |
| 3013 m_context->polygonOffset(factor, units); | 2955 m_context->polygonOffset(factor, units); |
| 3014 } | 2956 } |
| 3015 | 2957 |
| 3016 void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC 3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels) | 2958 void WebGLRenderingContextBase::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width , GC3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels) |
| 3017 { | 2959 { |
| 3018 if (isContextLost()) | 2960 if (isContextLost()) |
| 3019 return; | 2961 return; |
| 3020 // Due to WebGL's same-origin restrictions, it is not possible to | 2962 // Due to WebGL's same-origin restrictions, it is not possible to |
| 3021 // taint the origin using the WebGL API. | 2963 // taint the origin using the WebGL API. |
| 3022 ASSERT(canvas()->originClean()); | 2964 ASSERT(canvas()->originClean()); |
| 3023 // Validate input parameters. | 2965 // Validate input parameters. |
| 3024 if (!pixels) { | 2966 if (!pixels) { |
| 3025 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "readPixels", "no de stination ArrayBufferView"); | 2967 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "readPixels", "no de stination ArrayBufferView"); |
| 3026 return; | 2968 return; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 3052 if (pixels->getType() != ArrayBufferView::TypeUint8) { | 2994 if (pixels->getType() != ArrayBufferView::TypeUint8) { |
| 3053 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not Uint8Array"); | 2995 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not Uint8Array"); |
| 3054 return; | 2996 return; |
| 3055 } | 2997 } |
| 3056 const char* reason = "framebuffer incomplete"; | 2998 const char* reason = "framebuffer incomplete"; |
| 3057 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { | 2999 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { |
| 3058 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea dPixels", reason); | 3000 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea dPixels", reason); |
| 3059 return; | 3001 return; |
| 3060 } | 3002 } |
| 3061 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3003 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
| 3062 unsigned int totalBytesRequired = 0; | 3004 unsigned totalBytesRequired = 0; |
| 3063 unsigned int padding = 0; | 3005 unsigned padding = 0; |
| 3064 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_packAlignment, &totalBytesRequired, &padding); | 3006 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_packAlignment, &totalBytesRequired, &padding); |
| 3065 if (error != GraphicsContext3D::NO_ERROR) { | 3007 if (error != GraphicsContext3D::NO_ERROR) { |
| 3066 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3008 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
| 3067 return; | 3009 return; |
| 3068 } | 3010 } |
| 3069 if (pixels->byteLength() < totalBytesRequired) { | 3011 if (pixels->byteLength() < totalBytesRequired) { |
| 3070 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not large enough for dimensions"); | 3012 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not large enough for dimensions"); |
| 3071 return; | 3013 return; |
| 3072 } | 3014 } |
| 3073 | 3015 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 3088 for (GC3Dsizei ix = 0; ix < width; ++ix) { | 3030 for (GC3Dsizei ix = 0; ix < width; ++ix) { |
| 3089 pixels[3] = 255; | 3031 pixels[3] = 255; |
| 3090 pixels += 4; | 3032 pixels += 4; |
| 3091 } | 3033 } |
| 3092 pixels += padding; | 3034 pixels += padding; |
| 3093 } | 3035 } |
| 3094 } | 3036 } |
| 3095 #endif | 3037 #endif |
| 3096 } | 3038 } |
| 3097 | 3039 |
| 3098 void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum intern alformat, GC3Dsizei width, GC3Dsizei height) | 3040 void WebGLRenderingContextBase::renderbufferStorage(GC3Denum target, GC3Denum in ternalformat, GC3Dsizei width, GC3Dsizei height) |
| 3099 { | 3041 { |
| 3100 if (isContextLost()) | 3042 if (isContextLost()) |
| 3101 return; | 3043 return; |
| 3102 if (target != GraphicsContext3D::RENDERBUFFER) { | 3044 if (target != GraphicsContext3D::RENDERBUFFER) { |
| 3103 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid target"); | 3045 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid target"); |
| 3104 return; | 3046 return; |
| 3105 } | 3047 } |
| 3106 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 3048 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
| 3107 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto rage", "no bound renderbuffer"); | 3049 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto rage", "no bound renderbuffer"); |
| 3108 return; | 3050 return; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3139 m_renderbufferBinding->setSize(width, height); | 3081 m_renderbufferBinding->setSize(width, height); |
| 3140 m_renderbufferBinding->setInternalFormat(internalformat); | 3082 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3141 break; | 3083 break; |
| 3142 default: | 3084 default: |
| 3143 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid internalformat"); | 3085 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid internalformat"); |
| 3144 return; | 3086 return; |
| 3145 } | 3087 } |
| 3146 applyStencilTest(); | 3088 applyStencilTest(); |
| 3147 } | 3089 } |
| 3148 | 3090 |
| 3149 void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert) | 3091 void WebGLRenderingContextBase::sampleCoverage(GC3Dfloat value, GC3Dboolean inve rt) |
| 3150 { | 3092 { |
| 3151 if (isContextLost()) | 3093 if (isContextLost()) |
| 3152 return; | 3094 return; |
| 3153 m_context->sampleCoverage(value, invert); | 3095 m_context->sampleCoverage(value, invert); |
| 3154 } | 3096 } |
| 3155 | 3097 |
| 3156 void WebGLRenderingContext::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Ds izei height) | 3098 void WebGLRenderingContextBase::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, G C3Dsizei height) |
| 3157 { | 3099 { |
| 3158 if (isContextLost()) | 3100 if (isContextLost()) |
| 3159 return; | 3101 return; |
| 3160 if (!validateSize("scissor", width, height)) | 3102 if (!validateSize("scissor", width, height)) |
| 3161 return; | 3103 return; |
| 3162 m_context->scissor(x, y, width, height); | 3104 m_context->scissor(x, y, width, height); |
| 3163 } | 3105 } |
| 3164 | 3106 |
| 3165 void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri ng) | 3107 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String& string) |
| 3166 { | 3108 { |
| 3167 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 3109 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) |
| 3168 return; | 3110 return; |
| 3169 String stringWithoutComments = StripComments(string).result(); | 3111 String stringWithoutComments = StripComments(string).result(); |
| 3170 if (!validateString("shaderSource", stringWithoutComments)) | 3112 if (!validateString("shaderSource", stringWithoutComments)) |
| 3171 return; | 3113 return; |
| 3172 shader->setSource(string); | 3114 shader->setSource(string); |
| 3173 m_context->shaderSource(objectOrZero(shader), stringWithoutComments); | 3115 m_context->shaderSource(objectOrZero(shader), stringWithoutComments); |
| 3174 } | 3116 } |
| 3175 | 3117 |
| 3176 void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mas k) | 3118 void WebGLRenderingContextBase::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) |
| 3177 { | 3119 { |
| 3178 if (isContextLost()) | 3120 if (isContextLost()) |
| 3179 return; | 3121 return; |
| 3180 if (!validateStencilOrDepthFunc("stencilFunc", func)) | 3122 if (!validateStencilOrDepthFunc("stencilFunc", func)) |
| 3181 return; | 3123 return; |
| 3182 m_stencilFuncRef = ref; | 3124 m_stencilFuncRef = ref; |
| 3183 m_stencilFuncRefBack = ref; | 3125 m_stencilFuncRefBack = ref; |
| 3184 m_stencilFuncMask = mask; | 3126 m_stencilFuncMask = mask; |
| 3185 m_stencilFuncMaskBack = mask; | 3127 m_stencilFuncMaskBack = mask; |
| 3186 m_context->stencilFunc(func, ref, mask); | 3128 m_context->stencilFunc(func, ref, mask); |
| 3187 } | 3129 } |
| 3188 | 3130 |
| 3189 void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC 3Dint ref, GC3Duint mask) | 3131 void WebGLRenderingContextBase::stencilFuncSeparate(GC3Denum face, GC3Denum func , GC3Dint ref, GC3Duint mask) |
| 3190 { | 3132 { |
| 3191 if (isContextLost()) | 3133 if (isContextLost()) |
| 3192 return; | 3134 return; |
| 3193 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) | 3135 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) |
| 3194 return; | 3136 return; |
| 3195 switch (face) { | 3137 switch (face) { |
| 3196 case GraphicsContext3D::FRONT_AND_BACK: | 3138 case GraphicsContext3D::FRONT_AND_BACK: |
| 3197 m_stencilFuncRef = ref; | 3139 m_stencilFuncRef = ref; |
| 3198 m_stencilFuncRefBack = ref; | 3140 m_stencilFuncRefBack = ref; |
| 3199 m_stencilFuncMask = mask; | 3141 m_stencilFuncMask = mask; |
| 3200 m_stencilFuncMaskBack = mask; | 3142 m_stencilFuncMaskBack = mask; |
| 3201 break; | 3143 break; |
| 3202 case GraphicsContext3D::FRONT: | 3144 case GraphicsContext3D::FRONT: |
| 3203 m_stencilFuncRef = ref; | 3145 m_stencilFuncRef = ref; |
| 3204 m_stencilFuncMask = mask; | 3146 m_stencilFuncMask = mask; |
| 3205 break; | 3147 break; |
| 3206 case GraphicsContext3D::BACK: | 3148 case GraphicsContext3D::BACK: |
| 3207 m_stencilFuncRefBack = ref; | 3149 m_stencilFuncRefBack = ref; |
| 3208 m_stencilFuncMaskBack = mask; | 3150 m_stencilFuncMaskBack = mask; |
| 3209 break; | 3151 break; |
| 3210 default: | 3152 default: |
| 3211 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilFuncSeparate" , "invalid face"); | 3153 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilFuncSeparate" , "invalid face"); |
| 3212 return; | 3154 return; |
| 3213 } | 3155 } |
| 3214 m_context->stencilFuncSeparate(face, func, ref, mask); | 3156 m_context->stencilFuncSeparate(face, func, ref, mask); |
| 3215 } | 3157 } |
| 3216 | 3158 |
| 3217 void WebGLRenderingContext::stencilMask(GC3Duint mask) | 3159 void WebGLRenderingContextBase::stencilMask(GC3Duint mask) |
| 3218 { | 3160 { |
| 3219 if (isContextLost()) | 3161 if (isContextLost()) |
| 3220 return; | 3162 return; |
| 3221 m_stencilMask = mask; | 3163 m_stencilMask = mask; |
| 3222 m_stencilMaskBack = mask; | 3164 m_stencilMaskBack = mask; |
| 3223 m_context->stencilMask(mask); | 3165 m_context->stencilMask(mask); |
| 3224 } | 3166 } |
| 3225 | 3167 |
| 3226 void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask) | 3168 void WebGLRenderingContextBase::stencilMaskSeparate(GC3Denum face, GC3Duint mask ) |
| 3227 { | 3169 { |
| 3228 if (isContextLost()) | 3170 if (isContextLost()) |
| 3229 return; | 3171 return; |
| 3230 switch (face) { | 3172 switch (face) { |
| 3231 case GraphicsContext3D::FRONT_AND_BACK: | 3173 case GraphicsContext3D::FRONT_AND_BACK: |
| 3232 m_stencilMask = mask; | 3174 m_stencilMask = mask; |
| 3233 m_stencilMaskBack = mask; | 3175 m_stencilMaskBack = mask; |
| 3234 break; | 3176 break; |
| 3235 case GraphicsContext3D::FRONT: | 3177 case GraphicsContext3D::FRONT: |
| 3236 m_stencilMask = mask; | 3178 m_stencilMask = mask; |
| 3237 break; | 3179 break; |
| 3238 case GraphicsContext3D::BACK: | 3180 case GraphicsContext3D::BACK: |
| 3239 m_stencilMaskBack = mask; | 3181 m_stencilMaskBack = mask; |
| 3240 break; | 3182 break; |
| 3241 default: | 3183 default: |
| 3242 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilMaskSeparate" , "invalid face"); | 3184 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilMaskSeparate" , "invalid face"); |
| 3243 return; | 3185 return; |
| 3244 } | 3186 } |
| 3245 m_context->stencilMaskSeparate(face, mask); | 3187 m_context->stencilMaskSeparate(face, mask); |
| 3246 } | 3188 } |
| 3247 | 3189 |
| 3248 void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zp ass) | 3190 void WebGLRenderingContextBase::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denu m zpass) |
| 3249 { | 3191 { |
| 3250 if (isContextLost()) | 3192 if (isContextLost()) |
| 3251 return; | 3193 return; |
| 3252 m_context->stencilOp(fail, zfail, zpass); | 3194 m_context->stencilOp(fail, zfail, zpass); |
| 3253 } | 3195 } |
| 3254 | 3196 |
| 3255 void WebGLRenderingContext::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3D enum zfail, GC3Denum zpass) | 3197 void WebGLRenderingContextBase::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) |
| 3256 { | 3198 { |
| 3257 if (isContextLost()) | 3199 if (isContextLost()) |
| 3258 return; | 3200 return; |
| 3259 m_context->stencilOpSeparate(face, fail, zfail, zpass); | 3201 m_context->stencilOpSeparate(face, fail, zfail, zpass); |
| 3260 } | 3202 } |
| 3261 | 3203 |
| 3262 void WebGLRenderingContext::texImage2DBase(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels, ExceptionState& es) | 3204 void WebGLRenderingContextBase::texImage2DBase(GC3Denum target, GC3Dint level, G C3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3De num format, GC3Denum type, const void* pixels, ExceptionState& es) |
| 3263 { | 3205 { |
| 3264 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 3206 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
| 3265 // FIXME: Handle errors. | 3207 // FIXME: Handle errors. |
| 3266 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); | 3208 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); |
| 3267 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev el, internalformat, width, height, border, format, type)); | 3209 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev el, internalformat, width, height, border, format, type)); |
| 3268 ASSERT(tex); | 3210 ASSERT(tex); |
| 3269 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); | 3211 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); |
| 3270 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); | 3212 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); |
| 3271 m_context->texImage2D(target, level, internalformat, width, height, | 3213 m_context->texImage2D(target, level, internalformat, width, height, |
| 3272 border, format, type, pixels); | 3214 border, format, type, pixels); |
| 3273 tex->setLevelInfo(target, level, internalformat, width, height, type); | 3215 tex->setLevelInfo(target, level, internalformat, width, height, type); |
| 3274 } | 3216 } |
| 3275 | 3217 |
| 3276 void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContex t3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionS tate& es) | 3218 void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, G C3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsCo ntext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, Except ionState& es) |
| 3277 { | 3219 { |
| 3278 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 3220 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
| 3279 Vector<uint8_t> data; | 3221 Vector<uint8_t> data; |
| 3280 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); | 3222 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); |
| 3281 if (!imageExtractor.extractSucceeded()) { | 3223 if (!imageExtractor.extractSucceeded()) { |
| 3282 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad i mage data"); | 3224 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad i mage data"); |
| 3283 return; | 3225 return; |
| 3284 } | 3226 } |
| 3285 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat(); | 3227 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat(); |
| 3286 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); | 3228 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); |
| 3287 const void* imagePixelData = imageExtractor.imagePixelData(); | 3229 const void* imagePixelData = imageExtractor.imagePixelData(); |
| 3288 | 3230 |
| 3289 bool needConversion = true; | 3231 bool needConversion = true; |
| 3290 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr aphicsContext3D::AlphaDoNothing && !flipY) | 3232 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr aphicsContext3D::AlphaDoNothing && !flipY) { |
| 3291 needConversion = false; | 3233 needConversion = false; |
| 3292 else { | 3234 } else { |
| 3293 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { | 3235 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { |
| 3294 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "p ackImage error"); | 3236 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "p ackImage error"); |
| 3295 return; | 3237 return; |
| 3296 } | 3238 } |
| 3297 } | 3239 } |
| 3298 | 3240 |
| 3299 if (m_unpackAlignment != 1) | 3241 if (m_unpackAlignment != 1) |
| 3300 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3242 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); |
| 3301 texImage2DBase(target, level, internalformat, image->width(), image->height( ), 0, format, type, needConversion ? data.data() : imagePixelData, es); | 3243 texImage2DBase(target, level, internalformat, image->width(), image->height( ), 0, format, type, needConversion ? data.data() : imagePixelData, es); |
| 3302 if (m_unpackAlignment != 1) | 3244 if (m_unpackAlignment != 1) |
| 3303 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); | 3245 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); |
| 3304 } | 3246 } |
| 3305 | 3247 |
| 3306 bool WebGLRenderingContext::validateTexFunc(const char* functionName, TexFuncVal idationFunctionType functionType, TexFuncValidationSourceType sourceType, GC3Den um target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei he ight, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint xoffset, GC3Dint y offset) | 3248 bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexFun cValidationFunctionType functionType, TexFuncValidationSourceType sourceType, GC 3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsize i height, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint xoffset, GC3Di nt yoffset) |
| 3307 { | 3249 { |
| 3308 if (!validateTexFuncParameters(functionName, functionType, target, level, in ternalformat, width, height, border, format, type)) | 3250 if (!validateTexFuncParameters(functionName, functionType, target, level, in ternalformat, width, height, border, format, type)) |
| 3309 return false; | 3251 return false; |
| 3310 | 3252 |
| 3311 WebGLTexture* texture = validateTextureBinding(functionName, target, true); | 3253 WebGLTexture* texture = validateTextureBinding(functionName, target, true); |
| 3312 if (!texture) | 3254 if (!texture) |
| 3313 return false; | 3255 return false; |
| 3314 | 3256 |
| 3315 if (functionType == NotTexSubImage2D) { | 3257 if (functionType == NotTexSubImage2D) { |
| 3316 if (level && WebGLTexture::isNPOT(width, height)) { | 3258 if (level && WebGLTexture::isNPOT(width, height)) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3339 } | 3281 } |
| 3340 if (texture->getInternalFormat(target, level) != format || texture->getT ype(target, level) != type) { | 3282 if (texture->getInternalFormat(target, level) != format || texture->getT ype(target, level) != type) { |
| 3341 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type and format do not match texture"); | 3283 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type and format do not match texture"); |
| 3342 return false; | 3284 return false; |
| 3343 } | 3285 } |
| 3344 } | 3286 } |
| 3345 | 3287 |
| 3346 return true; | 3288 return true; |
| 3347 } | 3289 } |
| 3348 | 3290 |
| 3349 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, | 3291 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, |
| 3350 GC3Dsizei width, GC3Dsizei height, GC3Dint border, | 3292 GC3Dsizei width, GC3Dsizei height, GC3Dint border, |
| 3351 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionState& es) | 3293 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionState& es) |
| 3352 { | 3294 { |
| 3353 if (isContextLost() || !validateTexFuncData("texImage2D", level, width, heig ht, format, type, pixels, NullAllowed) | 3295 if (isContextLost() || !validateTexFuncData("texImage2D", level, width, heig ht, format, type, pixels, NullAllowed) |
| 3354 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferVie w, target, level, internalformat, width, height, border, format, type, 0, 0)) | 3296 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferVie w, target, level, internalformat, width, height, border, format, type, 0, 0)) |
| 3355 return; | 3297 return; |
| 3356 void* data = pixels ? pixels->baseAddress() : 0; | 3298 void* data = pixels ? pixels->baseAddress() : 0; |
| 3357 Vector<uint8_t> tempData; | 3299 Vector<uint8_t> tempData; |
| 3358 bool changeUnpackAlignment = false; | 3300 bool changeUnpackAlignment = false; |
| 3359 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 3301 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
| 3360 if (!m_context->extractTextureData(width, height, format, type, | 3302 if (!m_context->extractTextureData(width, height, format, type, |
| 3361 m_unpackAlignment, | 3303 m_unpackAlignment, |
| 3362 m_unpackFlipY, m_unpackPremultiplyAlp ha, | 3304 m_unpackFlipY, m_unpackPremultiplyAlpha, |
| 3363 data, | 3305 data, |
| 3364 tempData)) | 3306 tempData)) |
| 3365 return; | 3307 return; |
| 3366 data = tempData.data(); | 3308 data = tempData.data(); |
| 3367 changeUnpackAlignment = true; | 3309 changeUnpackAlignment = true; |
| 3368 } | 3310 } |
| 3369 if (changeUnpackAlignment) | 3311 if (changeUnpackAlignment) |
| 3370 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3312 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); |
| 3371 texImage2DBase(target, level, internalformat, width, height, border, format, type, data, es); | 3313 texImage2DBase(target, level, internalformat, width, height, border, format, type, data, es); |
| 3372 if (changeUnpackAlignment) | 3314 if (changeUnpackAlignment) |
| 3373 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); | 3315 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); |
| 3374 } | 3316 } |
| 3375 | 3317 |
| 3376 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, | 3318 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, |
| 3377 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& es) | 3319 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& es) |
| 3378 { | 3320 { |
| 3379 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels-> height(), 0, format, type, 0, 0)) | 3321 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels-> height(), 0, format, type, 0, 0)) |
| 3380 return; | 3322 return; |
| 3381 Vector<uint8_t> data; | 3323 Vector<uint8_t> data; |
| 3382 bool needConversion = true; | 3324 bool needConversion = true; |
| 3383 // The data from ImageData is always of format RGBA8. | 3325 // The data from ImageData is always of format RGBA8. |
| 3384 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. | 3326 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. |
| 3385 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GraphicsContext 3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE) | 3327 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GraphicsContext 3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE) { |
| 3386 needConversion = false; | 3328 needConversion = false; |
| 3387 else { | 3329 } else { |
| 3388 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_ unpackPremultiplyAlpha, data)) { | 3330 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_ unpackPremultiplyAlpha, data)) { |
| 3389 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); | 3331 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); |
| 3390 return; | 3332 return; |
| 3391 } | 3333 } |
| 3392 } | 3334 } |
| 3393 if (m_unpackAlignment != 1) | 3335 if (m_unpackAlignment != 1) |
| 3394 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3336 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); |
| 3395 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), es) ; | 3337 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), es) ; |
| 3396 if (m_unpackAlignment != 1) | 3338 if (m_unpackAlignment != 1) |
| 3397 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); | 3339 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); |
| 3398 } | 3340 } |
| 3399 | 3341 |
| 3400 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, | 3342 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, |
| 3401 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& es) | 3343 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& es) |
| 3402 { | 3344 { |
| 3403 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, es)) | 3345 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, es)) |
| 3404 return; | 3346 return; |
| 3405 Image* imageForRender = image->cachedImage()->imageForRenderer(image->render er()); | 3347 Image* imageForRender = image->cachedImage()->imageForRenderer(image->render er()); |
| 3406 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0)) | 3348 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0)) |
| 3407 return; | 3349 return; |
| 3408 | 3350 |
| 3409 texImage2DImpl(target, level, internalformat, format, type, imageForRender, GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, es); | 3351 texImage2DImpl(target, level, internalformat, format, type, imageForRender, GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, es); |
| 3410 } | 3352 } |
| 3411 | 3353 |
| 3412 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, | 3354 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, |
| 3413 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e s) | 3355 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e s) |
| 3414 { | 3356 { |
| 3415 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, es) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvasElement, tar get, level, internalformat, canvas->width(), canvas->height(), 0, format, type, 0, 0)) | 3357 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, es) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvasElement, tar get, level, internalformat, canvas->width(), canvas->height(), 0, format, type, 0, 0)) |
| 3416 return; | 3358 return; |
| 3417 | 3359 |
| 3418 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3360 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
| 3419 // If possible, copy from the canvas element directly to the texture | 3361 // If possible, copy from the canvas element directly to the texture |
| 3420 // via the GPU, without a read-back to system memory. | 3362 // via the GPU, without a read-back to system memory. |
| 3421 if (GraphicsContext3D::TEXTURE_2D == target && texture) { | 3363 if (GraphicsContext3D::TEXTURE_2D == target && texture) { |
| 3422 ImageBuffer* buffer = canvas->buffer(); | 3364 ImageBuffer* buffer = canvas->buffer(); |
| 3423 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->o bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3365 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->o bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3424 texture->setLevelInfo(target, level, internalformat, canvas->width() , canvas->height(), type); | 3366 texture->setLevelInfo(target, level, internalformat, canvas->width() , canvas->height(), type); |
| 3425 return; | 3367 return; |
| 3426 } | 3368 } |
| 3427 } | 3369 } |
| 3428 | 3370 |
| 3429 RefPtr<ImageData> imageData = canvas->getImageData(); | 3371 RefPtr<ImageData> imageData = canvas->getImageData(); |
| 3430 if (imageData) | 3372 if (imageData) |
| 3431 texImage2D(target, level, internalformat, format, type, imageData.get(), es); | 3373 texImage2D(target, level, internalformat, format, type, imageData.get(), es); |
| 3432 else | 3374 else |
| 3433 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyA lpha, es); | 3375 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyA lpha, es); |
| 3434 } | 3376 } |
| 3435 | 3377 |
| 3436 PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* vid eo, BackingStoreCopy backingStoreCopy) | 3378 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy) |
| 3437 { | 3379 { |
| 3438 IntSize size(video->videoWidth(), video->videoHeight()); | 3380 IntSize size(video->videoWidth(), video->videoHeight()); |
| 3439 ImageBuffer* buf = m_videoCache.imageBuffer(size); | 3381 ImageBuffer* buf = m_videoCache.imageBuffer(size); |
| 3440 if (!buf) { | 3382 if (!buf) { |
| 3441 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out o f memory"); | 3383 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out o f memory"); |
| 3442 return 0; | 3384 return 0; |
| 3443 } | 3385 } |
| 3444 IntRect destRect(0, 0, size.width(), size.height()); | 3386 IntRect destRect(0, 0, size.width(), size.height()); |
| 3445 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback. | 3387 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback. |
| 3446 video->paintCurrentFrameInContext(buf->context(), destRect); | 3388 video->paintCurrentFrameInContext(buf->context(), destRect); |
| 3447 return buf->copyImage(backingStoreCopy); | 3389 return buf->copyImage(backingStoreCopy); |
| 3448 } | 3390 } |
| 3449 | 3391 |
| 3450 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, | 3392 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, |
| 3451 GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionState& es) | 3393 GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionState& es) |
| 3452 { | 3394 { |
| 3453 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, es) | 3395 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, es) |
| 3454 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) | 3396 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) |
| 3455 return; | 3397 return; |
| 3456 | 3398 |
| 3457 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. | 3399 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. |
| 3458 // Otherwise, it will fall back to the normal SW path. | 3400 // Otherwise, it will fall back to the normal SW path. |
| 3459 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3401 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
| 3460 if (GraphicsContext3D::TEXTURE_2D == target && texture) { | 3402 if (GraphicsContext3D::TEXTURE_2D == target && texture) { |
| 3461 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3403 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3462 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type); | 3404 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type); |
| 3463 return; | 3405 return; |
| 3464 } | 3406 } |
| 3465 } | 3407 } |
| 3466 | 3408 |
| 3467 // Normal pure SW path. | 3409 // Normal pure SW path. |
| 3468 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); | 3410 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); |
| 3469 if (!image) | 3411 if (!image) |
| 3470 return; | 3412 return; |
| 3471 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, es); | 3413 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, es); |
| 3472 } | 3414 } |
| 3473 | 3415 |
| 3474 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl oat paramf, GC3Dint parami, bool isFloat) | 3416 void WebGLRenderingContextBase::texParameter(GC3Denum target, GC3Denum pname, GC 3Dfloat paramf, GC3Dint parami, bool isFloat) |
| 3475 { | 3417 { |
| 3476 if (isContextLost()) | 3418 if (isContextLost()) |
| 3477 return; | 3419 return; |
| 3478 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); | 3420 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); |
| 3479 if (!tex) | 3421 if (!tex) |
| 3480 return; | 3422 return; |
| 3481 switch (pname) { | 3423 switch (pname) { |
| 3482 case GraphicsContext3D::TEXTURE_MIN_FILTER: | 3424 case GraphicsContext3D::TEXTURE_MIN_FILTER: |
| 3483 case GraphicsContext3D::TEXTURE_MAG_FILTER: | 3425 case GraphicsContext3D::TEXTURE_MAG_FILTER: |
| 3484 break; | 3426 break; |
| 3485 case GraphicsContext3D::TEXTURE_WRAP_S: | 3427 case GraphicsContext3D::TEXTURE_WRAP_S: |
| 3486 case GraphicsContext3D::TEXTURE_WRAP_T: | 3428 case GraphicsContext3D::TEXTURE_WRAP_T: |
| 3487 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) | 3429 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) |
| 3488 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT)) { | 3430 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT)) { |
| 3489 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", " invalid parameter"); | 3431 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", " invalid parameter"); |
| 3490 return; | 3432 return; |
| 3491 } | 3433 } |
| 3492 break; | 3434 break; |
| 3493 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic | 3435 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic |
| 3494 if (!m_extTextureFilterAnisotropic) { | 3436 if (!extensionEnabled(EXTTextureFilterAnisotropicName)) { |
| 3495 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", " invalid parameter, EXT_texture_filter_anisotropic not enabled"); | 3437 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", " invalid parameter, EXT_texture_filter_anisotropic not enabled"); |
| 3496 return; | 3438 return; |
| 3497 } | 3439 } |
| 3498 break; | 3440 break; |
| 3499 default: | 3441 default: |
| 3500 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", "inva lid parameter name"); | 3442 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", "inva lid parameter name"); |
| 3501 return; | 3443 return; |
| 3502 } | 3444 } |
| 3503 if (isFloat) { | 3445 if (isFloat) { |
| 3504 tex->setParameterf(pname, paramf); | 3446 tex->setParameterf(pname, paramf); |
| 3505 m_context->texParameterf(target, pname, paramf); | 3447 m_context->texParameterf(target, pname, paramf); |
| 3506 } else { | 3448 } else { |
| 3507 tex->setParameteri(pname, parami); | 3449 tex->setParameteri(pname, parami); |
| 3508 m_context->texParameteri(target, pname, parami); | 3450 m_context->texParameteri(target, pname, parami); |
| 3509 } | 3451 } |
| 3510 } | 3452 } |
| 3511 | 3453 |
| 3512 void WebGLRenderingContext::texParameterf(GC3Denum target, GC3Denum pname, GC3Df loat param) | 3454 void WebGLRenderingContextBase::texParameterf(GC3Denum target, GC3Denum pname, G C3Dfloat param) |
| 3513 { | 3455 { |
| 3514 texParameter(target, pname, param, 0, true); | 3456 texParameter(target, pname, param, 0, true); |
| 3515 } | 3457 } |
| 3516 | 3458 |
| 3517 void WebGLRenderingContext::texParameteri(GC3Denum target, GC3Denum pname, GC3Di nt param) | 3459 void WebGLRenderingContextBase::texParameteri(GC3Denum target, GC3Denum pname, G C3Dint param) |
| 3518 { | 3460 { |
| 3519 texParameter(target, pname, 0, param, false); | 3461 texParameter(target, pname, 0, param, false); |
| 3520 } | 3462 } |
| 3521 | 3463 |
| 3522 void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum form at, GC3Denum type, const void* pixels, ExceptionState& es) | 3464 void WebGLRenderingContextBase::texSubImage2DBase(GC3Denum target, GC3Dint level , GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels, ExceptionState& es) |
| 3523 { | 3465 { |
| 3524 // FIXME: Handle errors. | 3466 // FIXME: Handle errors. |
| 3525 ASSERT(!isContextLost()); | 3467 ASSERT(!isContextLost()); |
| 3526 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, lev el, format, width, height, 0, format, type)); | 3468 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, lev el, format, width, height, 0, format, type)); |
| 3527 ASSERT(validateSize("texSubImage2D", xoffset, yoffset)); | 3469 ASSERT(validateSize("texSubImage2D", xoffset, yoffset)); |
| 3528 ASSERT(validateSettableTexFormat("texSubImage2D", format)); | 3470 ASSERT(validateSettableTexFormat("texSubImage2D", format)); |
| 3529 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); | 3471 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); |
| 3530 if (!tex) { | 3472 if (!tex) { |
| 3531 ASSERT_NOT_REACHED(); | 3473 ASSERT_NOT_REACHED(); |
| 3532 return; | 3474 return; |
| 3533 } | 3475 } |
| 3534 ASSERT((xoffset + width) >= 0); | 3476 ASSERT((xoffset + width) >= 0); |
| 3535 ASSERT((yoffset + height) >= 0); | 3477 ASSERT((yoffset + height) >= 0); |
| 3536 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); | 3478 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); |
| 3537 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); | 3479 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); |
| 3538 ASSERT(tex->getInternalFormat(target, level) == format); | 3480 ASSERT(tex->getInternalFormat(target, level) == format); |
| 3539 ASSERT(tex->getType(target, level) == type); | 3481 ASSERT(tex->getType(target, level) == type); |
| 3540 m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, for mat, type, pixels); | 3482 m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, for mat, type, pixels); |
| 3541 } | 3483 } |
| 3542 | 3484 |
| 3543 void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, Gr aphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha , ExceptionState& es) | 3485 void WebGLRenderingContextBase::texSubImage2DImpl(GC3Denum target, GC3Dint level , GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image , GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyA lpha, ExceptionState& es) |
| 3544 { | 3486 { |
| 3545 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 3487 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
| 3546 Vector<uint8_t> data; | 3488 Vector<uint8_t> data; |
| 3547 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); | 3489 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); |
| 3548 if (!imageExtractor.extractSucceeded()) { | 3490 if (!imageExtractor.extractSucceeded()) { |
| 3549 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "ba d image"); | 3491 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "ba d image"); |
| 3550 return; | 3492 return; |
| 3551 } | 3493 } |
| 3552 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat(); | 3494 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat(); |
| 3553 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); | 3495 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); |
| 3554 const void* imagePixelData = imageExtractor.imagePixelData(); | 3496 const void* imagePixelData = imageExtractor.imagePixelData(); |
| 3555 | 3497 |
| 3556 bool needConversion = true; | 3498 bool needConversion = true; |
| 3557 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr aphicsContext3D::AlphaDoNothing && !flipY) | 3499 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr aphicsContext3D::AlphaDoNothing && !flipY) { |
| 3558 needConversion = false; | 3500 needConversion = false; |
| 3559 else { | 3501 } else { |
| 3560 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { | 3502 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { |
| 3561 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); | 3503 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); |
| 3562 return; | 3504 return; |
| 3563 } | 3505 } |
| 3564 } | 3506 } |
| 3565 | 3507 |
| 3566 if (m_unpackAlignment != 1) | 3508 if (m_unpackAlignment != 1) |
| 3567 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3509 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); |
| 3568 texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->he ight(), format, type, needConversion ? data.data() : imagePixelData, es); | 3510 texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->he ight(), format, type, needConversion ? data.data() : imagePixelData, es); |
| 3569 if (m_unpackAlignment != 1) | 3511 if (m_unpackAlignment != 1) |
| 3570 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); | 3512 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); |
| 3571 } | 3513 } |
| 3572 | 3514 |
| 3573 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, | 3515 void WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, |
| 3574 GC3Dsizei width, GC3Dsizei height, | 3516 GC3Dsizei width, GC3Dsizei height, |
| 3575 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionState& es) | 3517 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionState& es) |
| 3576 { | 3518 { |
| 3577 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h eight, format, type, pixels, NullNotAllowed) | 3519 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h eight, format, type, pixels, NullNotAllowed) |
| 3578 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie w, target, level, format, width, height, 0, format, type, xoffset, yoffset)) | 3520 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie w, target, level, format, width, height, 0, format, type, xoffset, yoffset)) |
| 3579 return; | 3521 return; |
| 3580 void* data = pixels->baseAddress(); | 3522 void* data = pixels->baseAddress(); |
| 3581 Vector<uint8_t> tempData; | 3523 Vector<uint8_t> tempData; |
| 3582 bool changeUnpackAlignment = false; | 3524 bool changeUnpackAlignment = false; |
| 3583 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 3525 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
| 3584 if (!m_context->extractTextureData(width, height, format, type, | 3526 if (!m_context->extractTextureData(width, height, format, type, |
| 3585 m_unpackAlignment, | 3527 m_unpackAlignment, |
| 3586 m_unpackFlipY, m_unpackPremultiplyAlp ha, | 3528 m_unpackFlipY, m_unpackPremultiplyAlpha, |
| 3587 data, | 3529 data, |
| 3588 tempData)) | 3530 tempData)) |
| 3589 return; | 3531 return; |
| 3590 data = tempData.data(); | 3532 data = tempData.data(); |
| 3591 changeUnpackAlignment = true; | 3533 changeUnpackAlignment = true; |
| 3592 } | 3534 } |
| 3593 if (changeUnpackAlignment) | 3535 if (changeUnpackAlignment) |
| 3594 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3536 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); |
| 3595 texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, ty pe, data, es); | 3537 texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, ty pe, data, es); |
| 3596 if (changeUnpackAlignment) | 3538 if (changeUnpackAlignment) |
| 3597 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); | 3539 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); |
| 3598 } | 3540 } |
| 3599 | 3541 |
| 3600 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, | 3542 void WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, |
| 3601 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& es) | 3543 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& es) |
| 3602 { | 3544 { |
| 3603 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm age2D, SourceImageData, target, level, format, pixels->width(), pixels->height( ), 0, format, type, xoffset, yoffset)) | 3545 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm age2D, SourceImageData, target, level, format, pixels->width(), pixels->height( ), 0, format, type, xoffset, yoffset)) |
| 3604 return; | 3546 return; |
| 3605 | 3547 |
| 3606 Vector<uint8_t> data; | 3548 Vector<uint8_t> data; |
| 3607 bool needConversion = true; | 3549 bool needConversion = true; |
| 3608 // The data from ImageData is always of format RGBA8. | 3550 // The data from ImageData is always of format RGBA8. |
| 3609 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. | 3551 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. |
| 3610 if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED _BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha) | 3552 if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED _BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha) { |
| 3611 needConversion = false; | 3553 needConversion = false; |
| 3612 else { | 3554 } else { |
| 3613 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_ unpackPremultiplyAlpha, data)) { | 3555 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_ unpackPremultiplyAlpha, data)) { |
| 3614 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data"); | 3556 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data"); |
| 3615 return; | 3557 return; |
| 3616 } | 3558 } |
| 3617 } | 3559 } |
| 3618 if (m_unpackAlignment != 1) | 3560 if (m_unpackAlignment != 1) |
| 3619 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3561 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); |
| 3620 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels-> height(), format, type, needConversion ? data.data() : pixels->data()->data(), e s); | 3562 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels-> height(), format, type, needConversion ? data.data() : pixels->data()->data(), e s); |
| 3621 if (m_unpackAlignment != 1) | 3563 if (m_unpackAlignment != 1) |
| 3622 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); | 3564 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); |
| 3623 } | 3565 } |
| 3624 | 3566 |
| 3625 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, | 3567 void WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, |
| 3626 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& es) | 3568 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& es) |
| 3627 { | 3569 { |
| 3628 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, es) ) | 3570 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, es) ) |
| 3629 return; | 3571 return; |
| 3630 Image* imageForRender = image->cachedImage()->imageForRenderer(image->render er()); | 3572 Image* imageForRender = image->cachedImage()->imageForRenderer(image->render er()); |
| 3631 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceHTMLImageElement, target, level, format, imageForRender->width(), imageForRend er->height(), 0, format, type, xoffset, yoffset)) | 3573 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceHTMLImageElement, target, level, format, imageForRender->width(), imageForRend er->height(), 0, format, type, xoffset, yoffset)) |
| 3632 return; | 3574 return; |
| 3633 | 3575 |
| 3634 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der, GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, e s); | 3576 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der, GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, e s); |
| 3635 } | 3577 } |
| 3636 | 3578 |
| 3637 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, | 3579 void WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, |
| 3638 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e s) | 3580 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e s) |
| 3639 { | 3581 { |
| 3640 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e s) | 3582 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e s) |
| 3641 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) | 3583 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) |
| 3642 return; | 3584 return; |
| 3643 | 3585 |
| 3644 RefPtr<ImageData> imageData = canvas->getImageData(); | 3586 RefPtr<ImageData> imageData = canvas->getImageData(); |
| 3645 if (imageData) | 3587 if (imageData) |
| 3646 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.g et(), es); | 3588 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.g et(), es); |
| 3647 else | 3589 else |
| 3648 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas- >copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremult iplyAlpha, es); | 3590 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas- >copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremult iplyAlpha, es); |
| 3649 } | 3591 } |
| 3650 | 3592 |
| 3651 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, | 3593 void WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, |
| 3652 GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionState& es) | 3594 GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionState& es) |
| 3653 { | 3595 { |
| 3654 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, es) | 3596 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, es) |
| 3655 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset)) | 3597 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset)) |
| 3656 return; | 3598 return; |
| 3657 | 3599 |
| 3658 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); | 3600 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); |
| 3659 if (!image) | 3601 if (!image) |
| 3660 return; | 3602 return; |
| 3661 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, es); | 3603 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, es); |
| 3662 } | 3604 } |
| 3663 | 3605 |
| 3664 void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3D float x) | 3606 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location, GC3Dfloat x) |
| 3665 { | 3607 { |
| 3666 if (isContextLost() || !location) | 3608 if (isContextLost() || !location) |
| 3667 return; | 3609 return; |
| 3668 | 3610 |
| 3669 if (location->program() != m_currentProgram) { | 3611 if (location->program() != m_currentProgram) { |
| 3670 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "lo cation not for current program"); | 3612 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "lo cation not for current program"); |
| 3671 return; | 3613 return; |
| 3672 } | 3614 } |
| 3673 | 3615 |
| 3674 m_context->uniform1f(location->location(), x); | 3616 m_context->uniform1f(location->location(), x); |
| 3675 } | 3617 } |
| 3676 | 3618 |
| 3677 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo at32Array* v) | 3619 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, Float32Array* v) |
| 3678 { | 3620 { |
| 3679 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1)) | 3621 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1)) |
| 3680 return; | 3622 return; |
| 3681 | 3623 |
| 3682 m_context->uniform1fv(location->location(), v->length(), v->data()); | 3624 m_context->uniform1fv(location->location(), v->length(), v->data()); |
| 3683 } | 3625 } |
| 3684 | 3626 |
| 3685 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) | 3627 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size) |
| 3686 { | 3628 { |
| 3687 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1)) | 3629 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1)) |
| 3688 return; | 3630 return; |
| 3689 | 3631 |
| 3690 m_context->uniform1fv(location->location(), size, v); | 3632 m_context->uniform1fv(location->location(), size, v); |
| 3691 } | 3633 } |
| 3692 | 3634 |
| 3693 void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3D int x) | 3635 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location, GC3Dint x) |
| 3694 { | 3636 { |
| 3695 if (isContextLost() || !location) | 3637 if (isContextLost() || !location) |
| 3696 return; | 3638 return; |
| 3697 | 3639 |
| 3698 if (location->program() != m_currentProgram) { | 3640 if (location->program() != m_currentProgram) { |
| 3699 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "lo cation not for current program"); | 3641 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "lo cation not for current program"); |
| 3700 return; | 3642 return; |
| 3701 } | 3643 } |
| 3702 | 3644 |
| 3703 m_context->uniform1i(location->location(), x); | 3645 m_context->uniform1i(location->location(), x); |
| 3704 } | 3646 } |
| 3705 | 3647 |
| 3706 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int 32Array* v) | 3648 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, Int32Array* v) |
| 3707 { | 3649 { |
| 3708 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1)) | 3650 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1)) |
| 3709 return; | 3651 return; |
| 3710 | 3652 |
| 3711 m_context->uniform1iv(location->location(), v->length(), v->data()); | 3653 m_context->uniform1iv(location->location(), v->length(), v->data()); |
| 3712 } | 3654 } |
| 3713 | 3655 |
| 3714 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) | 3656 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size) |
| 3715 { | 3657 { |
| 3716 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1)) | 3658 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1)) |
| 3717 return; | 3659 return; |
| 3718 | 3660 |
| 3719 m_context->uniform1iv(location->location(), size, v); | 3661 m_context->uniform1iv(location->location(), size, v); |
| 3720 } | 3662 } |
| 3721 | 3663 |
| 3722 void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y) | 3664 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y) |
| 3723 { | 3665 { |
| 3724 if (isContextLost() || !location) | 3666 if (isContextLost() || !location) |
| 3725 return; | 3667 return; |
| 3726 | 3668 |
| 3727 if (location->program() != m_currentProgram) { | 3669 if (location->program() != m_currentProgram) { |
| 3728 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2f", "lo cation not for current program"); | 3670 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2f", "lo cation not for current program"); |
| 3729 return; | 3671 return; |
| 3730 } | 3672 } |
| 3731 | 3673 |
| 3732 m_context->uniform2f(location->location(), x, y); | 3674 m_context->uniform2f(location->location(), x, y); |
| 3733 } | 3675 } |
| 3734 | 3676 |
| 3735 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo at32Array* v) | 3677 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, Float32Array* v) |
| 3736 { | 3678 { |
| 3737 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2)) | 3679 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2)) |
| 3738 return; | 3680 return; |
| 3739 | 3681 |
| 3740 m_context->uniform2fv(location->location(), v->length() / 2, v->data()); | 3682 m_context->uniform2fv(location->location(), v->length() / 2, v->data()); |
| 3741 } | 3683 } |
| 3742 | 3684 |
| 3743 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) | 3685 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size) |
| 3744 { | 3686 { |
| 3745 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2)) | 3687 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2)) |
| 3746 return; | 3688 return; |
| 3747 | 3689 |
| 3748 m_context->uniform2fv(location->location(), size / 2, v); | 3690 m_context->uniform2fv(location->location(), size / 2, v); |
| 3749 } | 3691 } |
| 3750 | 3692 |
| 3751 void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y) | 3693 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y) |
| 3752 { | 3694 { |
| 3753 if (isContextLost() || !location) | 3695 if (isContextLost() || !location) |
| 3754 return; | 3696 return; |
| 3755 | 3697 |
| 3756 if (location->program() != m_currentProgram) { | 3698 if (location->program() != m_currentProgram) { |
| 3757 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2i", "lo cation not for current program"); | 3699 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2i", "lo cation not for current program"); |
| 3758 return; | 3700 return; |
| 3759 } | 3701 } |
| 3760 | 3702 |
| 3761 m_context->uniform2i(location->location(), x, y); | 3703 m_context->uniform2i(location->location(), x, y); |
| 3762 } | 3704 } |
| 3763 | 3705 |
| 3764 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int 32Array* v) | 3706 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, Int32Array* v) |
| 3765 { | 3707 { |
| 3766 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2)) | 3708 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2)) |
| 3767 return; | 3709 return; |
| 3768 | 3710 |
| 3769 m_context->uniform2iv(location->location(), v->length() / 2, v->data()); | 3711 m_context->uniform2iv(location->location(), v->length() / 2, v->data()); |
| 3770 } | 3712 } |
| 3771 | 3713 |
| 3772 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) | 3714 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size) |
| 3773 { | 3715 { |
| 3774 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2)) | 3716 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2)) |
| 3775 return; | 3717 return; |
| 3776 | 3718 |
| 3777 m_context->uniform2iv(location->location(), size / 2, v); | 3719 m_context->uniform2iv(location->location(), size / 2, v); |
| 3778 } | 3720 } |
| 3779 | 3721 |
| 3780 void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z) | 3722 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) |
| 3781 { | 3723 { |
| 3782 if (isContextLost() || !location) | 3724 if (isContextLost() || !location) |
| 3783 return; | 3725 return; |
| 3784 | 3726 |
| 3785 if (location->program() != m_currentProgram) { | 3727 if (location->program() != m_currentProgram) { |
| 3786 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3f", "lo cation not for current program"); | 3728 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3f", "lo cation not for current program"); |
| 3787 return; | 3729 return; |
| 3788 } | 3730 } |
| 3789 | 3731 |
| 3790 m_context->uniform3f(location->location(), x, y, z); | 3732 m_context->uniform3f(location->location(), x, y, z); |
| 3791 } | 3733 } |
| 3792 | 3734 |
| 3793 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo at32Array* v) | 3735 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, Float32Array* v) |
| 3794 { | 3736 { |
| 3795 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3)) | 3737 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3)) |
| 3796 return; | 3738 return; |
| 3797 | 3739 |
| 3798 m_context->uniform3fv(location->location(), v->length() / 3, v->data()); | 3740 m_context->uniform3fv(location->location(), v->length() / 3, v->data()); |
| 3799 } | 3741 } |
| 3800 | 3742 |
| 3801 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) | 3743 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size) |
| 3802 { | 3744 { |
| 3803 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3)) | 3745 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3)) |
| 3804 return; | 3746 return; |
| 3805 | 3747 |
| 3806 m_context->uniform3fv(location->location(), size / 3, v); | 3748 m_context->uniform3fv(location->location(), size / 3, v); |
| 3807 } | 3749 } |
| 3808 | 3750 |
| 3809 void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z) | 3751 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z) |
| 3810 { | 3752 { |
| 3811 if (isContextLost() || !location) | 3753 if (isContextLost() || !location) |
| 3812 return; | 3754 return; |
| 3813 | 3755 |
| 3814 if (location->program() != m_currentProgram) { | 3756 if (location->program() != m_currentProgram) { |
| 3815 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3i", "lo cation not for current program"); | 3757 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3i", "lo cation not for current program"); |
| 3816 return; | 3758 return; |
| 3817 } | 3759 } |
| 3818 | 3760 |
| 3819 m_context->uniform3i(location->location(), x, y, z); | 3761 m_context->uniform3i(location->location(), x, y, z); |
| 3820 } | 3762 } |
| 3821 | 3763 |
| 3822 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int 32Array* v) | 3764 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, Int32Array* v) |
| 3823 { | 3765 { |
| 3824 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3)) | 3766 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3)) |
| 3825 return; | 3767 return; |
| 3826 | 3768 |
| 3827 m_context->uniform3iv(location->location(), v->length() / 3, v->data()); | 3769 m_context->uniform3iv(location->location(), v->length() / 3, v->data()); |
| 3828 } | 3770 } |
| 3829 | 3771 |
| 3830 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) | 3772 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size) |
| 3831 { | 3773 { |
| 3832 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3)) | 3774 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3)) |
| 3833 return; | 3775 return; |
| 3834 | 3776 |
| 3835 m_context->uniform3iv(location->location(), size / 3, v); | 3777 m_context->uniform3iv(location->location(), size / 3, v); |
| 3836 } | 3778 } |
| 3837 | 3779 |
| 3838 void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) | 3780 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) |
| 3839 { | 3781 { |
| 3840 if (isContextLost() || !location) | 3782 if (isContextLost() || !location) |
| 3841 return; | 3783 return; |
| 3842 | 3784 |
| 3843 if (location->program() != m_currentProgram) { | 3785 if (location->program() != m_currentProgram) { |
| 3844 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4f", "lo cation not for current program"); | 3786 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4f", "lo cation not for current program"); |
| 3845 return; | 3787 return; |
| 3846 } | 3788 } |
| 3847 | 3789 |
| 3848 m_context->uniform4f(location->location(), x, y, z, w); | 3790 m_context->uniform4f(location->location(), x, y, z, w); |
| 3849 } | 3791 } |
| 3850 | 3792 |
| 3851 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo at32Array* v) | 3793 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, Float32Array* v) |
| 3852 { | 3794 { |
| 3853 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4)) | 3795 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4)) |
| 3854 return; | 3796 return; |
| 3855 | 3797 |
| 3856 m_context->uniform4fv(location->location(), v->length() / 4, v->data()); | 3798 m_context->uniform4fv(location->location(), v->length() / 4, v->data()); |
| 3857 } | 3799 } |
| 3858 | 3800 |
| 3859 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) | 3801 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size) |
| 3860 { | 3802 { |
| 3861 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4)) | 3803 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4)) |
| 3862 return; | 3804 return; |
| 3863 | 3805 |
| 3864 m_context->uniform4fv(location->location(), size / 4, v); | 3806 m_context->uniform4fv(location->location(), size / 4, v); |
| 3865 } | 3807 } |
| 3866 | 3808 |
| 3867 void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, GC3Dint w) | 3809 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w) |
| 3868 { | 3810 { |
| 3869 if (isContextLost() || !location) | 3811 if (isContextLost() || !location) |
| 3870 return; | 3812 return; |
| 3871 | 3813 |
| 3872 if (location->program() != m_currentProgram) { | 3814 if (location->program() != m_currentProgram) { |
| 3873 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4i", "lo cation not for current program"); | 3815 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4i", "lo cation not for current program"); |
| 3874 return; | 3816 return; |
| 3875 } | 3817 } |
| 3876 | 3818 |
| 3877 m_context->uniform4i(location->location(), x, y, z, w); | 3819 m_context->uniform4i(location->location(), x, y, z, w); |
| 3878 } | 3820 } |
| 3879 | 3821 |
| 3880 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int 32Array* v) | 3822 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, Int32Array* v) |
| 3881 { | 3823 { |
| 3882 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4)) | 3824 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4)) |
| 3883 return; | 3825 return; |
| 3884 | 3826 |
| 3885 m_context->uniform4iv(location->location(), v->length() / 4, v->data()); | 3827 m_context->uniform4iv(location->location(), v->length() / 4, v->data()); |
| 3886 } | 3828 } |
| 3887 | 3829 |
| 3888 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) | 3830 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size) |
| 3889 { | 3831 { |
| 3890 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, size, 4)) | 3832 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, size, 4)) |
| 3891 return; | 3833 return; |
| 3892 | 3834 |
| 3893 m_context->uniform4iv(location->location(), size / 4, v); | 3835 m_context->uniform4iv(location->location(), size / 4, v); |
| 3894 } | 3836 } |
| 3895 | 3837 |
| 3896 void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v) | 3838 void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* loc ation, GC3Dboolean transpose, Float32Array* v) |
| 3897 { | 3839 { |
| 3898 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, 4)) | 3840 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, 4)) |
| 3899 return; | 3841 return; |
| 3900 m_context->uniformMatrix2fv(location->location(), v->length() / 4, transpose , v->data()); | 3842 m_context->uniformMatrix2fv(location->location(), v->length() / 4, transpose , v->data()); |
| 3901 } | 3843 } |
| 3902 | 3844 |
| 3903 void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size) | 3845 void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* loc ation, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size) |
| 3904 { | 3846 { |
| 3905 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, size, 4)) | 3847 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, size, 4)) |
| 3906 return; | 3848 return; |
| 3907 m_context->uniformMatrix2fv(location->location(), size / 4, transpose, v); | 3849 m_context->uniformMatrix2fv(location->location(), size / 4, transpose, v); |
| 3908 } | 3850 } |
| 3909 | 3851 |
| 3910 void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v) | 3852 void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* loc ation, GC3Dboolean transpose, Float32Array* v) |
| 3911 { | 3853 { |
| 3912 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, 9)) | 3854 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, 9)) |
| 3913 return; | 3855 return; |
| 3914 m_context->uniformMatrix3fv(location->location(), v->length() / 9, transpose , v->data()); | 3856 m_context->uniformMatrix3fv(location->location(), v->length() / 9, transpose , v->data()); |
| 3915 } | 3857 } |
| 3916 | 3858 |
| 3917 void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size) | 3859 void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* loc ation, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size) |
| 3918 { | 3860 { |
| 3919 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, size, 9)) | 3861 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, size, 9)) |
| 3920 return; | 3862 return; |
| 3921 m_context->uniformMatrix3fv(location->location(), size / 9, transpose, v); | 3863 m_context->uniformMatrix3fv(location->location(), size / 9, transpose, v); |
| 3922 } | 3864 } |
| 3923 | 3865 |
| 3924 void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v) | 3866 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GC3Dboolean transpose, Float32Array* v) |
| 3925 { | 3867 { |
| 3926 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, 16)) | 3868 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, 16)) |
| 3927 return; | 3869 return; |
| 3928 m_context->uniformMatrix4fv(location->location(), v->length() / 16, transpos e, v->data()); | 3870 m_context->uniformMatrix4fv(location->location(), v->length() / 16, transpos e, v->data()); |
| 3929 } | 3871 } |
| 3930 | 3872 |
| 3931 void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size) | 3873 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size) |
| 3932 { | 3874 { |
| 3933 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, size, 16)) | 3875 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, size, 16)) |
| 3934 return; | 3876 return; |
| 3935 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); | 3877 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); |
| 3936 } | 3878 } |
| 3937 | 3879 |
| 3938 void WebGLRenderingContext::useProgram(WebGLProgram* program) | 3880 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) |
| 3939 { | 3881 { |
| 3940 bool deleted; | 3882 bool deleted; |
| 3941 if (!checkObjectToBeBound("useProgram", program, deleted)) | 3883 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 3942 return; | 3884 return; |
| 3943 if (deleted) | 3885 if (deleted) |
| 3944 program = 0; | 3886 program = 0; |
| 3945 if (program && !program->getLinkStatus()) { | 3887 if (program && !program->getLinkStatus()) { |
| 3946 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p rogram not valid"); | 3888 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p rogram not valid"); |
| 3947 return; | 3889 return; |
| 3948 } | 3890 } |
| 3949 if (m_currentProgram != program) { | 3891 if (m_currentProgram != program) { |
| 3950 if (m_currentProgram) | 3892 if (m_currentProgram) |
| 3951 m_currentProgram->onDetached(graphicsContext3D()); | 3893 m_currentProgram->onDetached(graphicsContext3D()); |
| 3952 m_currentProgram = program; | 3894 m_currentProgram = program; |
| 3953 m_context->useProgram(objectOrZero(program)); | 3895 m_context->useProgram(objectOrZero(program)); |
| 3954 if (program) | 3896 if (program) |
| 3955 program->onAttached(); | 3897 program->onAttached(); |
| 3956 } | 3898 } |
| 3957 } | 3899 } |
| 3958 | 3900 |
| 3959 void WebGLRenderingContext::validateProgram(WebGLProgram* program) | 3901 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) |
| 3960 { | 3902 { |
| 3961 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 3903 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
| 3962 return; | 3904 return; |
| 3963 m_context->validateProgram(objectOrZero(program)); | 3905 m_context->validateProgram(objectOrZero(program)); |
| 3964 } | 3906 } |
| 3965 | 3907 |
| 3966 void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) | 3908 void WebGLRenderingContextBase::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) |
| 3967 { | 3909 { |
| 3968 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); | 3910 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); |
| 3969 } | 3911 } |
| 3970 | 3912 |
| 3971 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v) | 3913 void WebGLRenderingContextBase::vertexAttrib1fv(GC3Duint index, Float32Array* v) |
| 3972 { | 3914 { |
| 3973 vertexAttribfvImpl("vertexAttrib1fv", index, v, 1); | 3915 vertexAttribfvImpl("vertexAttrib1fv", index, v, 1); |
| 3974 } | 3916 } |
| 3975 | 3917 |
| 3976 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, GC3Dfloat* v, GC3Dsi zei size) | 3918 void WebGLRenderingContextBase::vertexAttrib1fv(GC3Duint index, GC3Dfloat* v, GC 3Dsizei size) |
| 3977 { | 3919 { |
| 3978 vertexAttribfvImpl("vertexAttrib1fv", index, v, size, 1); | 3920 vertexAttribfvImpl("vertexAttrib1fv", index, v, size, 1); |
| 3979 } | 3921 } |
| 3980 | 3922 |
| 3981 void WebGLRenderingContext::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dflo at v1) | 3923 void WebGLRenderingContextBase::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3 Dfloat v1) |
| 3982 { | 3924 { |
| 3983 vertexAttribfImpl("vertexAttrib2f", index, 2, v0, v1, 0.0f, 1.0f); | 3925 vertexAttribfImpl("vertexAttrib2f", index, 2, v0, v1, 0.0f, 1.0f); |
| 3984 } | 3926 } |
| 3985 | 3927 |
| 3986 void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, Float32Array* v) | 3928 void WebGLRenderingContextBase::vertexAttrib2fv(GC3Duint index, Float32Array* v) |
| 3987 { | 3929 { |
| 3988 vertexAttribfvImpl("vertexAttrib2fv", index, v, 2); | 3930 vertexAttribfvImpl("vertexAttrib2fv", index, v, 2); |
| 3989 } | 3931 } |
| 3990 | 3932 |
| 3991 void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, GC3Dfloat* v, GC3Dsi zei size) | 3933 void WebGLRenderingContextBase::vertexAttrib2fv(GC3Duint index, GC3Dfloat* v, GC 3Dsizei size) |
| 3992 { | 3934 { |
| 3993 vertexAttribfvImpl("vertexAttrib2fv", index, v, size, 2); | 3935 vertexAttribfvImpl("vertexAttrib2fv", index, v, size, 2); |
| 3994 } | 3936 } |
| 3995 | 3937 |
| 3996 void WebGLRenderingContext::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dflo at v1, GC3Dfloat v2) | 3938 void WebGLRenderingContextBase::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3 Dfloat v1, GC3Dfloat v2) |
| 3997 { | 3939 { |
| 3998 vertexAttribfImpl("vertexAttrib3f", index, 3, v0, v1, v2, 1.0f); | 3940 vertexAttribfImpl("vertexAttrib3f", index, 3, v0, v1, v2, 1.0f); |
| 3999 } | 3941 } |
| 4000 | 3942 |
| 4001 void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, Float32Array* v) | 3943 void WebGLRenderingContextBase::vertexAttrib3fv(GC3Duint index, Float32Array* v) |
| 4002 { | 3944 { |
| 4003 vertexAttribfvImpl("vertexAttrib3fv", index, v, 3); | 3945 vertexAttribfvImpl("vertexAttrib3fv", index, v, 3); |
| 4004 } | 3946 } |
| 4005 | 3947 |
| 4006 void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, GC3Dfloat* v, GC3Dsi zei size) | 3948 void WebGLRenderingContextBase::vertexAttrib3fv(GC3Duint index, GC3Dfloat* v, GC 3Dsizei size) |
| 4007 { | 3949 { |
| 4008 vertexAttribfvImpl("vertexAttrib3fv", index, v, size, 3); | 3950 vertexAttribfvImpl("vertexAttrib3fv", index, v, size, 3); |
| 4009 } | 3951 } |
| 4010 | 3952 |
| 4011 void WebGLRenderingContext::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dflo at v1, GC3Dfloat v2, GC3Dfloat v3) | 3953 void WebGLRenderingContextBase::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3 Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) |
| 4012 { | 3954 { |
| 4013 vertexAttribfImpl("vertexAttrib4f", index, 4, v0, v1, v2, v3); | 3955 vertexAttribfImpl("vertexAttrib4f", index, 4, v0, v1, v2, v3); |
| 4014 } | 3956 } |
| 4015 | 3957 |
| 4016 void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, Float32Array* v) | 3958 void WebGLRenderingContextBase::vertexAttrib4fv(GC3Duint index, Float32Array* v) |
| 4017 { | 3959 { |
| 4018 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); | 3960 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); |
| 4019 } | 3961 } |
| 4020 | 3962 |
| 4021 void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC3Dsi zei size) | 3963 void WebGLRenderingContextBase::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC 3Dsizei size) |
| 4022 { | 3964 { |
| 4023 vertexAttribfvImpl("vertexAttrib4fv", index, v, size, 4); | 3965 vertexAttribfvImpl("vertexAttrib4fv", index, v, size, 4); |
| 4024 } | 3966 } |
| 4025 | 3967 |
| 4026 void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC 3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset) | 3968 void WebGLRenderingContextBase::vertexAttribPointer(GC3Duint index, GC3Dint size , GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset) |
| 4027 { | 3969 { |
| 4028 if (isContextLost()) | 3970 if (isContextLost()) |
| 4029 return; | 3971 return; |
| 4030 switch (type) { | 3972 switch (type) { |
| 4031 case GraphicsContext3D::BYTE: | 3973 case GraphicsContext3D::BYTE: |
| 4032 case GraphicsContext3D::UNSIGNED_BYTE: | 3974 case GraphicsContext3D::UNSIGNED_BYTE: |
| 4033 case GraphicsContext3D::SHORT: | 3975 case GraphicsContext3D::SHORT: |
| 4034 case GraphicsContext3D::UNSIGNED_SHORT: | 3976 case GraphicsContext3D::UNSIGNED_SHORT: |
| 4035 case GraphicsContext3D::FLOAT: | 3977 case GraphicsContext3D::FLOAT: |
| 4036 break; | 3978 break; |
| 4037 default: | 3979 default: |
| 4038 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); | 3980 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); |
| 4039 return; | 3981 return; |
| 4040 } | 3982 } |
| 4041 if (index >= m_maxVertexAttribs) { | 3983 if (index >= m_maxVertexAttribs) { |
| 4042 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer ", "index out of range"); | 3984 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer ", "index out of range"); |
| 4043 return; | 3985 return; |
| 4044 } | 3986 } |
| 4045 if (size < 1 || size > 4 || stride < 0 || stride > 255 || offset < 0) { | 3987 if (size < 1 || size > 4 || stride < 0 || stride > 255 || offset < 0) { |
| 4046 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer ", "bad size, stride or offset"); | 3988 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer ", "bad size, stride or offset"); |
| 4047 return; | 3989 return; |
| 4048 } | 3990 } |
| 4049 if (!m_boundArrayBuffer) { | 3991 if (!m_boundArrayBuffer) { |
| 4050 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "no bound ARRAY_BUFFER"); | 3992 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "no bound ARRAY_BUFFER"); |
| 4051 return; | 3993 return; |
| 4052 } | 3994 } |
| 4053 // Determine the number of elements the bound buffer can hold, given the off set, size, type and stride | 3995 // Determine the number of elements the bound buffer can hold, given the off set, size, type and stride |
| 4054 unsigned int typeSize = sizeInBytes(type); | 3996 unsigned typeSize = sizeInBytes(type); |
| 4055 if (!typeSize) { | 3997 if (!typeSize) { |
| 4056 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); | 3998 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); |
| 4057 return; | 3999 return; |
| 4058 } | 4000 } |
| 4059 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { | 4001 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { |
| 4060 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "stride or offset not valid for type"); | 4002 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "stride or offset not valid for type"); |
| 4061 return; | 4003 return; |
| 4062 } | 4004 } |
| 4063 GC3Dsizei bytesPerElement = size * typeSize; | 4005 GC3Dsizei bytesPerElement = size * typeSize; |
| 4064 | 4006 |
| 4065 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); | 4007 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); |
| 4066 m_context->vertexAttribPointer(index, size, type, normalized, stride, static _cast<GC3Dintptr>(offset)); | 4008 m_context->vertexAttribPointer(index, size, type, normalized, stride, static _cast<GC3Dintptr>(offset)); |
| 4067 } | 4009 } |
| 4068 | 4010 |
| 4069 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di visor) | 4011 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GC3Duint index, GC3Duin t divisor) |
| 4070 { | 4012 { |
| 4071 if (isContextLost()) | 4013 if (isContextLost()) |
| 4072 return; | 4014 return; |
| 4073 | 4015 |
| 4074 if (index >= m_maxVertexAttribs) { | 4016 if (index >= m_maxVertexAttribs) { |
| 4075 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribDivisor ANGLE", "index out of range"); | 4017 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribDivisor ANGLE", "index out of range"); |
| 4076 return; | 4018 return; |
| 4077 } | 4019 } |
| 4078 | 4020 |
| 4079 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); | 4021 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); |
| 4080 m_context->getExtensions()->vertexAttribDivisorANGLE(index, divisor); | 4022 m_context->getExtensions()->vertexAttribDivisorANGLE(index, divisor); |
| 4081 } | 4023 } |
| 4082 | 4024 |
| 4083 void WebGLRenderingContext::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3D sizei height) | 4025 void WebGLRenderingContextBase::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) |
| 4084 { | 4026 { |
| 4085 if (isContextLost()) | 4027 if (isContextLost()) |
| 4086 return; | 4028 return; |
| 4087 if (!validateSize("viewport", width, height)) | 4029 if (!validateSize("viewport", width, height)) |
| 4088 return; | 4030 return; |
| 4089 m_context->viewport(x, y, width, height); | 4031 m_context->viewport(x, y, width, height); |
| 4090 } | 4032 } |
| 4091 | 4033 |
| 4092 void WebGLRenderingContext::forceLostContext(WebGLRenderingContext::LostContextM ode mode) | 4034 void WebGLRenderingContextBase::forceLostContext(WebGLRenderingContextBase::Lost ContextMode mode) |
| 4093 { | 4035 { |
| 4094 if (isContextLost()) { | 4036 if (isContextLost()) { |
| 4095 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "loseContext", " context already lost"); | 4037 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "loseContext", " context already lost"); |
| 4096 return; | 4038 return; |
| 4097 } | 4039 } |
| 4098 | 4040 |
| 4099 m_contextGroup->loseContextGroup(mode); | 4041 m_contextGroup->loseContextGroup(mode); |
| 4100 } | 4042 } |
| 4101 | 4043 |
| 4102 void WebGLRenderingContext::loseContextImpl(WebGLRenderingContext::LostContextMo de mode) | 4044 void WebGLRenderingContextBase::loseContextImpl(WebGLRenderingContextBase::LostC ontextMode mode) |
| 4103 { | 4045 { |
| 4104 if (isContextLost()) | 4046 if (isContextLost()) |
| 4105 return; | 4047 return; |
| 4106 | 4048 |
| 4107 m_contextLost = true; | 4049 m_contextLost = true; |
| 4108 m_contextLostMode = mode; | 4050 m_contextLostMode = mode; |
| 4109 | 4051 |
| 4110 if (mode == RealLostContext) { | 4052 if (mode == RealLostContext) { |
| 4111 // Inform the embedder that a lost context was received. In response, th e embedder might | 4053 // Inform the embedder that a lost context was received. In response, th e embedder might |
| 4112 // decide to take action such as asking the user for permission to use W ebGL again. | 4054 // decide to take action such as asking the user for permission to use W ebGL again. |
| 4113 if (Frame* frame = canvas()->document().frame()) | 4055 if (Frame* frame = canvas()->document().frame()) |
| 4114 frame->loader()->client()->didLoseWebGLContext(m_context->getExtensi ons()->getGraphicsResetStatusARB()); | 4056 frame->loader()->client()->didLoseWebGLContext(m_context->getExtensi ons()->getGraphicsResetStatusARB()); |
| 4115 } | 4057 } |
| 4116 | 4058 |
| 4117 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. | 4059 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. |
| 4118 m_drawingBuffer->setTexture2DBinding(0); | 4060 m_drawingBuffer->setTexture2DBinding(0); |
| 4119 m_drawingBuffer->setFramebufferBinding(0); | 4061 m_drawingBuffer->setFramebufferBinding(0); |
| 4120 | 4062 |
| 4121 detachAndRemoveAllObjects(); | 4063 detachAndRemoveAllObjects(); |
| 4122 | 4064 |
| 4123 // Lose all the extensions. | 4065 // Lose all the extensions. |
| 4124 for (size_t i = 0; i < m_extensions.size(); ++i) { | 4066 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 4125 ExtensionTracker* tracker = m_extensions[i]; | 4067 ExtensionTracker* tracker = m_extensions[i]; |
| 4126 tracker->loseExtension(); | 4068 tracker->loseExtension(); |
| 4127 } | 4069 } |
| 4128 | 4070 |
| 4071 for (int ii = 0; ii < WebGLExtensionNameCount; ++ii) | |
| 4072 m_extensionEnabled[ii] = 0; | |
| 4073 | |
| 4129 removeAllCompressedTextureFormats(); | 4074 removeAllCompressedTextureFormats(); |
| 4130 | 4075 |
| 4131 if (mode != RealLostContext) | 4076 if (mode != RealLostContext) |
| 4132 destroyGraphicsContext3D(); | 4077 destroyGraphicsContext3D(); |
| 4133 | 4078 |
| 4134 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole; | 4079 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole; |
| 4135 synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "con text lost", display); | 4080 synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "con text lost", display); |
| 4136 | 4081 |
| 4137 // Don't allow restoration unless the context lost event has both been | 4082 // Don't allow restoration unless the context lost event has both been |
| 4138 // dispatched and its default behavior prevented. | 4083 // dispatched and its default behavior prevented. |
| 4139 m_restoreAllowed = false; | 4084 m_restoreAllowed = false; |
| 4140 | 4085 |
| 4141 // Always defer the dispatch of the context lost event, to implement | 4086 // Always defer the dispatch of the context lost event, to implement |
| 4142 // the spec behavior of queueing a task. | 4087 // the spec behavior of queueing a task. |
| 4143 m_dispatchContextLostEventTimer.startOneShot(0); | 4088 m_dispatchContextLostEventTimer.startOneShot(0); |
| 4144 } | 4089 } |
| 4145 | 4090 |
| 4146 void WebGLRenderingContext::forceRestoreContext() | 4091 void WebGLRenderingContextBase::forceRestoreContext() |
| 4147 { | 4092 { |
| 4148 if (!isContextLost()) { | 4093 if (!isContextLost()) { |
| 4149 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext" , "context not lost"); | 4094 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext" , "context not lost"); |
| 4150 return; | 4095 return; |
| 4151 } | 4096 } |
| 4152 | 4097 |
| 4153 if (!m_restoreAllowed) { | 4098 if (!m_restoreAllowed) { |
| 4154 if (m_contextLostMode == SyntheticLostContext) | 4099 if (m_contextLostMode == SyntheticLostContext) |
| 4155 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreCont ext", "context restoration not allowed"); | 4100 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreCont ext", "context restoration not allowed"); |
| 4156 return; | 4101 return; |
| 4157 } | 4102 } |
| 4158 | 4103 |
| 4159 if (!m_restoreTimer.isActive()) | 4104 if (!m_restoreTimer.isActive()) |
| 4160 m_restoreTimer.startOneShot(0); | 4105 m_restoreTimer.startOneShot(0); |
| 4161 } | 4106 } |
| 4162 | 4107 |
| 4163 WebKit::WebLayer* WebGLRenderingContext::platformLayer() const | 4108 WebKit::WebLayer* WebGLRenderingContextBase::platformLayer() const |
| 4164 { | 4109 { |
| 4165 return m_drawingBuffer->platformLayer(); | 4110 return m_drawingBuffer->platformLayer(); |
| 4166 } | 4111 } |
| 4167 | 4112 |
| 4168 void WebGLRenderingContext::removeSharedObject(WebGLSharedObject* object) | 4113 void WebGLRenderingContextBase::removeSharedObject(WebGLSharedObject* object) |
| 4169 { | 4114 { |
| 4170 m_contextGroup->removeObject(object); | 4115 m_contextGroup->removeObject(object); |
| 4171 } | 4116 } |
| 4172 | 4117 |
| 4173 void WebGLRenderingContext::addSharedObject(WebGLSharedObject* object) | 4118 void WebGLRenderingContextBase::addSharedObject(WebGLSharedObject* object) |
| 4174 { | 4119 { |
| 4175 ASSERT(!isContextLost()); | 4120 ASSERT(!isContextLost()); |
| 4176 m_contextGroup->addObject(object); | 4121 m_contextGroup->addObject(object); |
| 4177 } | 4122 } |
| 4178 | 4123 |
| 4179 void WebGLRenderingContext::removeContextObject(WebGLContextObject* object) | 4124 void WebGLRenderingContextBase::removeContextObject(WebGLContextObject* object) |
| 4180 { | 4125 { |
| 4181 m_contextObjects.remove(object); | 4126 m_contextObjects.remove(object); |
| 4182 } | 4127 } |
| 4183 | 4128 |
| 4184 void WebGLRenderingContext::addContextObject(WebGLContextObject* object) | 4129 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) |
| 4185 { | 4130 { |
| 4186 ASSERT(!isContextLost()); | 4131 ASSERT(!isContextLost()); |
| 4187 m_contextObjects.add(object); | 4132 m_contextObjects.add(object); |
| 4188 } | 4133 } |
| 4189 | 4134 |
| 4190 void WebGLRenderingContext::detachAndRemoveAllObjects() | 4135 void WebGLRenderingContextBase::detachAndRemoveAllObjects() |
| 4191 { | 4136 { |
| 4192 while (m_contextObjects.size() > 0) { | 4137 while (m_contextObjects.size() > 0) { |
| 4193 HashSet<WebGLContextObject*>::iterator it = m_contextObjects.begin(); | 4138 HashSet<WebGLContextObject*>::iterator it = m_contextObjects.begin(); |
| 4194 (*it)->detachContext(); | 4139 (*it)->detachContext(); |
| 4195 } | 4140 } |
| 4196 } | 4141 } |
| 4197 | 4142 |
| 4198 bool WebGLRenderingContext::hasPendingActivity() const | 4143 bool WebGLRenderingContextBase::hasPendingActivity() const |
| 4199 { | 4144 { |
| 4200 return false; | 4145 return false; |
| 4201 } | 4146 } |
| 4202 | 4147 |
| 4203 void WebGLRenderingContext::stop() | 4148 void WebGLRenderingContextBase::stop() |
| 4204 { | 4149 { |
| 4205 if (!isContextLost()) { | 4150 if (!isContextLost()) { |
| 4206 forceLostContext(SyntheticLostContext); | 4151 forceLostContext(SyntheticLostContext); |
| 4207 destroyGraphicsContext3D(); | 4152 destroyGraphicsContext3D(); |
| 4208 } | 4153 } |
| 4209 } | 4154 } |
| 4210 | 4155 |
| 4211 WebGLGetInfo WebGLRenderingContext::getBooleanParameter(GC3Denum pname) | 4156 WebGLGetInfo WebGLRenderingContextBase::getBooleanParameter(GC3Denum pname) |
| 4212 { | 4157 { |
| 4213 GC3Dboolean value = 0; | 4158 GC3Dboolean value = 0; |
| 4214 if (!isContextLost()) | 4159 if (!isContextLost()) |
| 4215 m_context->getBooleanv(pname, &value); | 4160 m_context->getBooleanv(pname, &value); |
| 4216 return WebGLGetInfo(static_cast<bool>(value)); | 4161 return WebGLGetInfo(static_cast<bool>(value)); |
| 4217 } | 4162 } |
| 4218 | 4163 |
| 4219 WebGLGetInfo WebGLRenderingContext::getBooleanArrayParameter(GC3Denum pname) | 4164 WebGLGetInfo WebGLRenderingContextBase::getBooleanArrayParameter(GC3Denum pname) |
| 4220 { | 4165 { |
| 4221 if (pname != GraphicsContext3D::COLOR_WRITEMASK) { | 4166 if (pname != GraphicsContext3D::COLOR_WRITEMASK) { |
| 4222 notImplemented(); | 4167 notImplemented(); |
| 4223 return WebGLGetInfo(0, 0); | 4168 return WebGLGetInfo(0, 0); |
| 4224 } | 4169 } |
| 4225 GC3Dboolean value[4] = {0}; | 4170 GC3Dboolean value[4] = {0}; |
| 4226 if (!isContextLost()) | 4171 if (!isContextLost()) |
| 4227 m_context->getBooleanv(pname, value); | 4172 m_context->getBooleanv(pname, value); |
| 4228 bool boolValue[4]; | 4173 bool boolValue[4]; |
| 4229 for (int ii = 0; ii < 4; ++ii) | 4174 for (int ii = 0; ii < 4; ++ii) |
| 4230 boolValue[ii] = static_cast<bool>(value[ii]); | 4175 boolValue[ii] = static_cast<bool>(value[ii]); |
| 4231 return WebGLGetInfo(boolValue, 4); | 4176 return WebGLGetInfo(boolValue, 4); |
| 4232 } | 4177 } |
| 4233 | 4178 |
| 4234 WebGLGetInfo WebGLRenderingContext::getFloatParameter(GC3Denum pname) | 4179 WebGLGetInfo WebGLRenderingContextBase::getFloatParameter(GC3Denum pname) |
| 4235 { | 4180 { |
| 4236 GC3Dfloat value = 0; | 4181 GC3Dfloat value = 0; |
| 4237 if (!isContextLost()) | 4182 if (!isContextLost()) |
| 4238 m_context->getFloatv(pname, &value); | 4183 m_context->getFloatv(pname, &value); |
| 4239 return WebGLGetInfo(value); | 4184 return WebGLGetInfo(value); |
| 4240 } | 4185 } |
| 4241 | 4186 |
| 4242 WebGLGetInfo WebGLRenderingContext::getIntParameter(GC3Denum pname) | 4187 WebGLGetInfo WebGLRenderingContextBase::getIntParameter(GC3Denum pname) |
| 4243 { | 4188 { |
| 4244 GC3Dint value = 0; | 4189 GC3Dint value = 0; |
| 4245 if (!isContextLost()) | 4190 if (!isContextLost()) |
| 4246 m_context->getIntegerv(pname, &value); | 4191 m_context->getIntegerv(pname, &value); |
| 4247 return WebGLGetInfo(value); | 4192 return WebGLGetInfo(value); |
| 4248 } | 4193 } |
| 4249 | 4194 |
| 4250 WebGLGetInfo WebGLRenderingContext::getUnsignedIntParameter(GC3Denum pname) | 4195 WebGLGetInfo WebGLRenderingContextBase::getUnsignedIntParameter(GC3Denum pname) |
| 4251 { | 4196 { |
| 4252 GC3Dint value = 0; | 4197 GC3Dint value = 0; |
| 4253 if (!isContextLost()) | 4198 if (!isContextLost()) |
| 4254 m_context->getIntegerv(pname, &value); | 4199 m_context->getIntegerv(pname, &value); |
| 4255 return WebGLGetInfo(static_cast<unsigned int>(value)); | 4200 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 4256 } | 4201 } |
| 4257 | 4202 |
| 4258 WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(GC3Denum pname) | 4203 WebGLGetInfo WebGLRenderingContextBase::getWebGLFloatArrayParameter(GC3Denum pna me) |
| 4259 { | 4204 { |
| 4260 GC3Dfloat value[4] = {0}; | 4205 GC3Dfloat value[4] = {0}; |
| 4261 if (!isContextLost()) | 4206 if (!isContextLost()) |
| 4262 m_context->getFloatv(pname, value); | 4207 m_context->getFloatv(pname, value); |
| 4263 unsigned length = 0; | 4208 unsigned length = 0; |
| 4264 switch (pname) { | 4209 switch (pname) { |
| 4265 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: | 4210 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: |
| 4266 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: | 4211 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: |
| 4267 case GraphicsContext3D::DEPTH_RANGE: | 4212 case GraphicsContext3D::DEPTH_RANGE: |
| 4268 length = 2; | 4213 length = 2; |
| 4269 break; | 4214 break; |
| 4270 case GraphicsContext3D::BLEND_COLOR: | 4215 case GraphicsContext3D::BLEND_COLOR: |
| 4271 case GraphicsContext3D::COLOR_CLEAR_VALUE: | 4216 case GraphicsContext3D::COLOR_CLEAR_VALUE: |
| 4272 length = 4; | 4217 length = 4; |
| 4273 break; | 4218 break; |
| 4274 default: | 4219 default: |
| 4275 notImplemented(); | 4220 notImplemented(); |
| 4276 } | 4221 } |
| 4277 return WebGLGetInfo(Float32Array::create(value, length)); | 4222 return WebGLGetInfo(Float32Array::create(value, length)); |
| 4278 } | 4223 } |
| 4279 | 4224 |
| 4280 WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(GC3Denum pname) | 4225 WebGLGetInfo WebGLRenderingContextBase::getWebGLIntArrayParameter(GC3Denum pname ) |
| 4281 { | 4226 { |
| 4282 GC3Dint value[4] = {0}; | 4227 GC3Dint value[4] = {0}; |
| 4283 if (!isContextLost()) | 4228 if (!isContextLost()) |
| 4284 m_context->getIntegerv(pname, value); | 4229 m_context->getIntegerv(pname, value); |
| 4285 unsigned length = 0; | 4230 unsigned length = 0; |
| 4286 switch (pname) { | 4231 switch (pname) { |
| 4287 case GraphicsContext3D::MAX_VIEWPORT_DIMS: | 4232 case GraphicsContext3D::MAX_VIEWPORT_DIMS: |
| 4288 length = 2; | 4233 length = 2; |
| 4289 break; | 4234 break; |
| 4290 case GraphicsContext3D::SCISSOR_BOX: | 4235 case GraphicsContext3D::SCISSOR_BOX: |
| 4291 case GraphicsContext3D::VIEWPORT: | 4236 case GraphicsContext3D::VIEWPORT: |
| 4292 length = 4; | 4237 length = 4; |
| 4293 break; | 4238 break; |
| 4294 default: | 4239 default: |
| 4295 notImplemented(); | 4240 notImplemented(); |
| 4296 } | 4241 } |
| 4297 return WebGLGetInfo(Int32Array::create(value, length)); | 4242 return WebGLGetInfo(Int32Array::create(value, length)); |
| 4298 } | 4243 } |
| 4299 | 4244 |
| 4300 void WebGLRenderingContext::handleTextureCompleteness(const char* functionName, bool prepareToDraw) | 4245 void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa me, bool prepareToDraw) |
| 4301 { | 4246 { |
| 4302 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 4247 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
| 4303 bool resetActiveUnit = false; | 4248 bool resetActiveUnit = false; |
| 4304 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE xtensionFlag>((m_oesTextureFloatLinear ? WebGLTexture::TextureFloatLinearExtensi onEnabled : 0) | 4249 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE xtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::Textu reFloatLinearExtensionEnabled : 0) |
| 4305 | (m_oesTextureHalfFloatLinear ? WebGLTexture::TextureHalfFloatLinearExt ensionEnabled : 0)); | 4250 | (extensionEnabled(OESTextureHalfFloatLinearName) ? WebGLTexture::Textu reHalfFloatLinearExtensionEnabled : 0)); |
| 4306 for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { | 4251 for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { |
| 4307 if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m _texture2DBinding->needToUseBlackTexture(flag)) | 4252 if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m _texture2DBinding->needToUseBlackTexture(flag)) |
| 4308 || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUni ts[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) { | 4253 || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUni ts[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) { |
| 4309 if (ii != m_activeTextureUnit) { | 4254 if (ii != m_activeTextureUnit) { |
| 4310 m_context->activeTexture(ii); | 4255 m_context->activeTexture(ii); |
| 4311 resetActiveUnit = true; | 4256 resetActiveUnit = true; |
| 4312 } else if (resetActiveUnit) { | 4257 } else if (resetActiveUnit) { |
| 4313 m_context->activeTexture(ii); | 4258 m_context->activeTexture(ii); |
| 4314 resetActiveUnit = false; | 4259 resetActiveUnit = false; |
| 4315 } | 4260 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 4329 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te xture2DBinding->needToUseBlackTexture(flag)) | 4274 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te xture2DBinding->needToUseBlackTexture(flag)) |
| 4330 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZe ro(tex2D)); | 4275 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZe ro(tex2D)); |
| 4331 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii] .m_textureCubeMapBinding->needToUseBlackTexture(flag)) | 4276 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii] .m_textureCubeMapBinding->needToUseBlackTexture(flag)) |
| 4332 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, obje ctOrZero(texCubeMap)); | 4277 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, obje ctOrZero(texCubeMap)); |
| 4333 } | 4278 } |
| 4334 } | 4279 } |
| 4335 if (resetActiveUnit) | 4280 if (resetActiveUnit) |
| 4336 m_context->activeTexture(m_activeTextureUnit); | 4281 m_context->activeTexture(m_activeTextureUnit); |
| 4337 } | 4282 } |
| 4338 | 4283 |
| 4339 void WebGLRenderingContext::createFallbackBlackTextures1x1() | 4284 void WebGLRenderingContextBase::createFallbackBlackTextures1x1() |
| 4340 { | 4285 { |
| 4341 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 4286 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
| 4342 unsigned char black[] = {0, 0, 0, 255}; | 4287 unsigned char black[] = {0, 0, 0, 255}; |
| 4343 m_blackTexture2D = createTexture(); | 4288 m_blackTexture2D = createTexture(); |
| 4344 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D->obje ct()); | 4289 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D->obje ct()); |
| 4345 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::R GBA, 1, 1, | 4290 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::R GBA, 1, 1, |
| 4346 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4291 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4347 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); | 4292 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); |
| 4348 m_blackTextureCubeMap = createTexture(); | 4293 m_blackTextureCubeMap = createTexture(); |
| 4349 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, m_blackTextureCu beMap->object()); | 4294 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, m_blackTextureCu beMap->object()); |
| 4350 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X, 0, Gra phicsContext3D::RGBA, 1, 1, | 4295 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X, 0, Gra phicsContext3D::RGBA, 1, 1, |
| 4351 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4296 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4352 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X, 0, Gra phicsContext3D::RGBA, 1, 1, | 4297 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X, 0, Gra phicsContext3D::RGBA, 1, 1, |
| 4353 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4298 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4354 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y, 0, Gra phicsContext3D::RGBA, 1, 1, | 4299 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y, 0, Gra phicsContext3D::RGBA, 1, 1, |
| 4355 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4300 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4356 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, Gra phicsContext3D::RGBA, 1, 1, | 4301 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, Gra phicsContext3D::RGBA, 1, 1, |
| 4357 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4302 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4358 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z, 0, Gra phicsContext3D::RGBA, 1, 1, | 4303 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z, 0, Gra phicsContext3D::RGBA, 1, 1, |
| 4359 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4304 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4360 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, Gra phicsContext3D::RGBA, 1, 1, | 4305 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, Gra phicsContext3D::RGBA, 1, 1, |
| 4361 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); | 4306 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black); |
| 4362 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0); | 4307 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0); |
| 4363 } | 4308 } |
| 4364 | 4309 |
| 4365 bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(GC3De num texInternalFormat, | 4310 bool WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid(G C3Denum texInternalFormat, GC3Denum colorBufferFormat) |
| 4366 GC3De num colorBufferFormat) | |
| 4367 { | 4311 { |
| 4368 unsigned need = GraphicsContext3D::getChannelBitsByFormat(texInternalFormat) ; | 4312 unsigned need = GraphicsContext3D::getChannelBitsByFormat(texInternalFormat) ; |
| 4369 unsigned have = GraphicsContext3D::getChannelBitsByFormat(colorBufferFormat) ; | 4313 unsigned have = GraphicsContext3D::getChannelBitsByFormat(colorBufferFormat) ; |
| 4370 return (need & have) == need; | 4314 return (need & have) == need; |
| 4371 } | 4315 } |
| 4372 | 4316 |
| 4373 GC3Denum WebGLRenderingContext::getBoundFramebufferColorFormat() | 4317 GC3Denum WebGLRenderingContextBase::getBoundFramebufferColorFormat() |
| 4374 { | 4318 { |
| 4375 if (m_framebufferBinding && m_framebufferBinding->object()) | 4319 if (m_framebufferBinding && m_framebufferBinding->object()) |
| 4376 return m_framebufferBinding->getColorBufferFormat(); | 4320 return m_framebufferBinding->getColorBufferFormat(); |
| 4377 if (m_attributes.alpha) | 4321 if (m_attributes.alpha) |
| 4378 return GraphicsContext3D::RGBA; | 4322 return GraphicsContext3D::RGBA; |
| 4379 return GraphicsContext3D::RGB; | 4323 return GraphicsContext3D::RGB; |
| 4380 } | 4324 } |
| 4381 | 4325 |
| 4382 int WebGLRenderingContext::getBoundFramebufferWidth() | 4326 int WebGLRenderingContextBase::getBoundFramebufferWidth() |
| 4383 { | 4327 { |
| 4384 if (m_framebufferBinding && m_framebufferBinding->object()) | 4328 if (m_framebufferBinding && m_framebufferBinding->object()) |
| 4385 return m_framebufferBinding->getColorBufferWidth(); | 4329 return m_framebufferBinding->getColorBufferWidth(); |
| 4386 return m_drawingBuffer->size().width(); | 4330 return m_drawingBuffer->size().width(); |
| 4387 } | 4331 } |
| 4388 | 4332 |
| 4389 int WebGLRenderingContext::getBoundFramebufferHeight() | 4333 int WebGLRenderingContextBase::getBoundFramebufferHeight() |
| 4390 { | 4334 { |
| 4391 if (m_framebufferBinding && m_framebufferBinding->object()) | 4335 if (m_framebufferBinding && m_framebufferBinding->object()) |
| 4392 return m_framebufferBinding->getColorBufferHeight(); | 4336 return m_framebufferBinding->getColorBufferHeight(); |
| 4393 return m_drawingBuffer->size().height(); | 4337 return m_drawingBuffer->size().height(); |
| 4394 } | 4338 } |
| 4395 | 4339 |
| 4396 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function Name, GC3Denum target, bool useSixEnumsForCubeMap) | 4340 WebGLTexture* WebGLRenderingContextBase::validateTextureBinding(const char* func tionName, GC3Denum target, bool useSixEnumsForCubeMap) |
| 4397 { | 4341 { |
| 4398 WebGLTexture* tex = 0; | 4342 WebGLTexture* tex = 0; |
| 4399 switch (target) { | 4343 switch (target) { |
| 4400 case GraphicsContext3D::TEXTURE_2D: | 4344 case GraphicsContext3D::TEXTURE_2D: |
| 4401 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); | 4345 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); |
| 4402 break; | 4346 break; |
| 4403 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: | 4347 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: |
| 4404 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: | 4348 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 4405 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: | 4349 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 4406 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: | 4350 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 4421 break; | 4365 break; |
| 4422 default: | 4366 default: |
| 4423 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture target"); | 4367 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture target"); |
| 4424 return 0; | 4368 return 0; |
| 4425 } | 4369 } |
| 4426 if (!tex) | 4370 if (!tex) |
| 4427 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o texture"); | 4371 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o texture"); |
| 4428 return tex; | 4372 return tex; |
| 4429 } | 4373 } |
| 4430 | 4374 |
| 4431 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con st String& string) | 4375 bool WebGLRenderingContextBase::validateLocationLength(const char* functionName, const String& string) |
| 4432 { | 4376 { |
| 4433 const unsigned maxWebGLLocationLength = 256; | 4377 const unsigned maxWebGLLocationLength = 256; |
| 4434 if (string.length() > maxWebGLLocationLength) { | 4378 if (string.length() > maxWebGLLocationLength) { |
| 4435 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat ion length > 256"); | 4379 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat ion length > 256"); |
| 4436 return false; | 4380 return false; |
| 4437 } | 4381 } |
| 4438 return true; | 4382 return true; |
| 4439 } | 4383 } |
| 4440 | 4384 |
| 4441 bool WebGLRenderingContext::validateSize(const char* functionName, GC3Dint x, GC 3Dint y) | 4385 bool WebGLRenderingContextBase::validateSize(const char* functionName, GC3Dint x , GC3Dint y) |
| 4442 { | 4386 { |
| 4443 if (x < 0 || y < 0) { | 4387 if (x < 0 || y < 0) { |
| 4444 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "size < 0"); | 4388 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "size < 0"); |
| 4445 return false; | 4389 return false; |
| 4446 } | 4390 } |
| 4447 return true; | 4391 return true; |
| 4448 } | 4392 } |
| 4449 | 4393 |
| 4450 bool WebGLRenderingContext::validateString(const char* functionName, const Strin g& string) | 4394 bool WebGLRenderingContextBase::validateString(const char* functionName, const S tring& string) |
| 4451 { | 4395 { |
| 4452 for (size_t i = 0; i < string.length(); ++i) { | 4396 for (size_t i = 0; i < string.length(); ++i) { |
| 4453 if (!validateCharacter(string[i])) { | 4397 if (!validateCharacter(string[i])) { |
| 4454 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "s tring not ASCII"); | 4398 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "s tring not ASCII"); |
| 4455 return false; | 4399 return false; |
| 4456 } | 4400 } |
| 4457 } | 4401 } |
| 4458 return true; | 4402 return true; |
| 4459 } | 4403 } |
| 4460 | 4404 |
| 4461 bool WebGLRenderingContext::validateTexFuncFormatAndType(const char* functionNam e, GC3Denum format, GC3Denum type, GC3Dint level) | 4405 bool WebGLRenderingContextBase::validateTexFuncFormatAndType(const char* functio nName, GC3Denum format, GC3Denum type, GC3Dint level) |
| 4462 { | 4406 { |
| 4463 switch (format) { | 4407 switch (format) { |
| 4464 case GraphicsContext3D::ALPHA: | 4408 case GraphicsContext3D::ALPHA: |
| 4465 case GraphicsContext3D::LUMINANCE: | 4409 case GraphicsContext3D::LUMINANCE: |
| 4466 case GraphicsContext3D::LUMINANCE_ALPHA: | 4410 case GraphicsContext3D::LUMINANCE_ALPHA: |
| 4467 case GraphicsContext3D::RGB: | 4411 case GraphicsContext3D::RGB: |
| 4468 case GraphicsContext3D::RGBA: | 4412 case GraphicsContext3D::RGBA: |
| 4469 break; | 4413 break; |
| 4470 case GraphicsContext3D::DEPTH_STENCIL: | 4414 case GraphicsContext3D::DEPTH_STENCIL: |
| 4471 case GraphicsContext3D::DEPTH_COMPONENT: | 4415 case GraphicsContext3D::DEPTH_COMPONENT: |
| 4472 if (m_webglDepthTexture) | 4416 if (extensionEnabled(WebGLDepthTextureName)) |
| 4473 break; | 4417 break; |
| 4474 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "depth texture formats not enabled"); | 4418 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "depth texture formats not enabled"); |
| 4475 return false; | 4419 return false; |
| 4476 default: | 4420 default: |
| 4477 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture format"); | 4421 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture format"); |
| 4478 return false; | 4422 return false; |
| 4479 } | 4423 } |
| 4480 | 4424 |
| 4481 switch (type) { | 4425 switch (type) { |
| 4482 case GraphicsContext3D::UNSIGNED_BYTE: | 4426 case GraphicsContext3D::UNSIGNED_BYTE: |
| 4483 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: | 4427 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: |
| 4484 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: | 4428 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: |
| 4485 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: | 4429 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: |
| 4486 break; | 4430 break; |
| 4487 case GraphicsContext3D::FLOAT: | 4431 case GraphicsContext3D::FLOAT: |
| 4488 if (m_oesTextureFloat) | 4432 if (extensionEnabled(OESTextureFloatName)) |
| 4489 break; | 4433 break; |
| 4490 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); | 4434 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); |
| 4491 return false; | 4435 return false; |
| 4492 case GraphicsContext3D::HALF_FLOAT_OES: | 4436 case GraphicsContext3D::HALF_FLOAT_OES: |
| 4493 if (m_oesTextureHalfFloat) | 4437 if (extensionEnabled(OESTextureHalfFloatName)) |
| 4494 break; | 4438 break; |
| 4495 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); | 4439 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); |
| 4496 return false; | 4440 return false; |
| 4497 case GraphicsContext3D::UNSIGNED_INT: | 4441 case GraphicsContext3D::UNSIGNED_INT: |
| 4498 case GraphicsContext3D::UNSIGNED_INT_24_8: | 4442 case GraphicsContext3D::UNSIGNED_INT_24_8: |
| 4499 case GraphicsContext3D::UNSIGNED_SHORT: | 4443 case GraphicsContext3D::UNSIGNED_SHORT: |
| 4500 if (m_webglDepthTexture) | 4444 if (extensionEnabled(WebGLDepthTextureName)) |
| 4501 break; | 4445 break; |
| 4502 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); | 4446 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); |
| 4503 return false; | 4447 return false; |
| 4504 default: | 4448 default: |
| 4505 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); | 4449 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); |
| 4506 return false; | 4450 return false; |
| 4507 } | 4451 } |
| 4508 | 4452 |
| 4509 // Verify that the combination of format and type is supported. | 4453 // Verify that the combination of format and type is supported. |
| 4510 switch (format) { | 4454 switch (format) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 4531 if (type != GraphicsContext3D::UNSIGNED_BYTE | 4475 if (type != GraphicsContext3D::UNSIGNED_BYTE |
| 4532 && type != GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4 | 4476 && type != GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4 |
| 4533 && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1 | 4477 && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1 |
| 4534 && type != GraphicsContext3D::FLOAT | 4478 && type != GraphicsContext3D::FLOAT |
| 4535 && type != GraphicsContext3D::HALF_FLOAT_OES) { | 4479 && type != GraphicsContext3D::HALF_FLOAT_OES) { |
| 4536 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for RGBA format"); | 4480 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for RGBA format"); |
| 4537 return false; | 4481 return false; |
| 4538 } | 4482 } |
| 4539 break; | 4483 break; |
| 4540 case GraphicsContext3D::DEPTH_COMPONENT: | 4484 case GraphicsContext3D::DEPTH_COMPONENT: |
| 4541 if (!m_webglDepthTexture) { | 4485 if (!extensionEnabled(WebGLDepthTextureName)) { |
| 4542 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid format. DEPTH_COMPONENT not enabled"); | 4486 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid format. DEPTH_COMPONENT not enabled"); |
| 4543 return false; | 4487 return false; |
| 4544 } | 4488 } |
| 4545 if (type != GraphicsContext3D::UNSIGNED_SHORT | 4489 if (type != GraphicsContext3D::UNSIGNED_SHORT |
| 4546 && type != GraphicsContext3D::UNSIGNED_INT) { | 4490 && type != GraphicsContext3D::UNSIGNED_INT) { |
| 4547 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for DEPTH_COMPONENT format"); | 4491 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for DEPTH_COMPONENT format"); |
| 4548 return false; | 4492 return false; |
| 4549 } | 4493 } |
| 4550 if (level > 0) { | 4494 if (level > 0) { |
| 4551 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "level must be 0 for DEPTH_COMPONENT format"); | 4495 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "level must be 0 for DEPTH_COMPONENT format"); |
| 4552 return false; | 4496 return false; |
| 4553 } | 4497 } |
| 4554 break; | 4498 break; |
| 4555 case GraphicsContext3D::DEPTH_STENCIL: | 4499 case GraphicsContext3D::DEPTH_STENCIL: |
| 4556 if (!m_webglDepthTexture) { | 4500 if (!extensionEnabled(WebGLDepthTextureName)) { |
| 4557 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid format. DEPTH_STENCIL not enabled"); | 4501 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid format. DEPTH_STENCIL not enabled"); |
| 4558 return false; | 4502 return false; |
| 4559 } | 4503 } |
| 4560 if (type != GraphicsContext3D::UNSIGNED_INT_24_8) { | 4504 if (type != GraphicsContext3D::UNSIGNED_INT_24_8) { |
| 4561 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for DEPTH_STENCIL format"); | 4505 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for DEPTH_STENCIL format"); |
| 4562 return false; | 4506 return false; |
| 4563 } | 4507 } |
| 4564 if (level > 0) { | 4508 if (level > 0) { |
| 4565 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "level must be 0 for DEPTH_STENCIL format"); | 4509 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "level must be 0 for DEPTH_STENCIL format"); |
| 4566 return false; | 4510 return false; |
| 4567 } | 4511 } |
| 4568 break; | 4512 break; |
| 4569 default: | 4513 default: |
| 4570 ASSERT_NOT_REACHED(); | 4514 ASSERT_NOT_REACHED(); |
| 4571 } | 4515 } |
| 4572 | 4516 |
| 4573 return true; | 4517 return true; |
| 4574 } | 4518 } |
| 4575 | 4519 |
| 4576 bool WebGLRenderingContext::validateTexFuncLevel(const char* functionName, GC3De num target, GC3Dint level) | 4520 bool WebGLRenderingContextBase::validateTexFuncLevel(const char* functionName, G C3Denum target, GC3Dint level) |
| 4577 { | 4521 { |
| 4578 if (level < 0) { | 4522 if (level < 0) { |
| 4579 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level < 0"); | 4523 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level < 0"); |
| 4580 return false; | 4524 return false; |
| 4581 } | 4525 } |
| 4582 switch (target) { | 4526 switch (target) { |
| 4583 case GraphicsContext3D::TEXTURE_2D: | 4527 case GraphicsContext3D::TEXTURE_2D: |
| 4584 if (level >= m_maxTextureLevel) { | 4528 if (level >= m_maxTextureLevel) { |
| 4585 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel out of range"); | 4529 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel out of range"); |
| 4586 return false; | 4530 return false; |
| 4587 } | 4531 } |
| 4588 break; | 4532 break; |
| 4589 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: | 4533 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: |
| 4590 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: | 4534 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 4591 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: | 4535 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 4592 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: | 4536 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 4593 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: | 4537 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 4594 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: | 4538 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 4595 if (level >= m_maxCubeMapTextureLevel) { | 4539 if (level >= m_maxCubeMapTextureLevel) { |
| 4596 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel out of range"); | 4540 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel out of range"); |
| 4597 return false; | 4541 return false; |
| 4598 } | 4542 } |
| 4599 break; | 4543 break; |
| 4600 } | 4544 } |
| 4601 // This function only checks if level is legal, so we return true and don't | 4545 // This function only checks if level is legal, so we return true and don't |
| 4602 // generate INVALID_ENUM if target is illegal. | 4546 // generate INVALID_ENUM if target is illegal. |
| 4603 return true; | 4547 return true; |
| 4604 } | 4548 } |
| 4605 | 4549 |
| 4606 bool WebGLRenderingContext::validateTexFuncDimensions(const char* functionName, TexFuncValidationFunctionType functionType, | 4550 bool WebGLRenderingContextBase::validateTexFuncDimensions(const char* functionNa me, TexFuncValidationFunctionType functionType, |
| 4607 GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei height) | 4551 GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei height) |
| 4608 { | 4552 { |
| 4609 if (width < 0 || height < 0) { | 4553 if (width < 0 || height < 0) { |
| 4610 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); | 4554 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); |
| 4611 return false; | 4555 return false; |
| 4612 } | 4556 } |
| 4613 | 4557 |
| 4614 switch (target) { | 4558 switch (target) { |
| 4615 case GraphicsContext3D::TEXTURE_2D: | 4559 case GraphicsContext3D::TEXTURE_2D: |
| 4616 if (width > (m_maxTextureSize >> level) || height > (m_maxTextureSize >> level)) { | 4560 if (width > (m_maxTextureSize >> level) || height > (m_maxTextureSize >> level)) { |
| 4617 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth or height out of range"); | 4561 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth or height out of range"); |
| 4618 return false; | 4562 return false; |
| 4619 } | 4563 } |
| 4620 break; | 4564 break; |
| 4621 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: | 4565 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: |
| 4622 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: | 4566 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 4623 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: | 4567 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 4624 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: | 4568 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 4625 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: | 4569 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 4626 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: | 4570 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 4627 if (functionType != TexSubImage2D && width != height) { | 4571 if (functionType != TexSubImage2D && width != height) { |
| 4628 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "wid th != height for cube map"); | 4572 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth != height for cube map"); |
| 4629 return false; | 4573 return false; |
| 4630 } | 4574 } |
| 4631 // No need to check height here. For texImage width == height. | 4575 // No need to check height here. For texImage width == height. |
| 4632 // For texSubImage that will be checked when checking yoffset + height i s in range. | 4576 // For texSubImage that will be checked when checking yoffset + height i s in range. |
| 4633 if (width > (m_maxCubeMapTextureSize >> level)) { | 4577 if (width > (m_maxCubeMapTextureSize >> level)) { |
| 4634 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth or height out of range for cube map"); | 4578 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth or height out of range for cube map"); |
| 4635 return false; | 4579 return false; |
| 4636 } | 4580 } |
| 4637 break; | 4581 break; |
| 4638 default: | 4582 default: |
| 4639 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); | 4583 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); |
| 4640 return false; | 4584 return false; |
| 4641 } | 4585 } |
| 4642 return true; | 4586 return true; |
| 4643 } | 4587 } |
| 4644 | 4588 |
| 4645 bool WebGLRenderingContext::validateTexFuncParameters(const char* functionName, TexFuncValidationFunctionType functionType, GC3Denum target, | 4589 bool WebGLRenderingContextBase::validateTexFuncParameters(const char* functionNa me, TexFuncValidationFunctionType functionType, GC3Denum target, |
| 4646 GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, G C3Dint border, GC3Denum format, GC3Denum type) | 4590 GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, G C3Dint border, GC3Denum format, GC3Denum type) |
| 4647 { | 4591 { |
| 4648 // We absolutely have to validate the format and type combination. | 4592 // We absolutely have to validate the format and type combination. |
| 4649 // The texImage2D entry points taking HTMLImage, etc. will produce | 4593 // The texImage2D entry points taking HTMLImage, etc. will produce |
| 4650 // temporary data based on this combination, so it must be legal. | 4594 // temporary data based on this combination, so it must be legal. |
| 4651 if (!validateTexFuncFormatAndType(functionName, format, type, level) || !val idateTexFuncLevel(functionName, target, level)) | 4595 if (!validateTexFuncFormatAndType(functionName, format, type, level) || !val idateTexFuncLevel(functionName, target, level)) |
| 4652 return false; | 4596 return false; |
| 4653 | 4597 |
| 4654 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) | 4598 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) |
| 4655 return false; | 4599 return false; |
| 4656 | 4600 |
| 4657 if (format != internalformat) { | 4601 if (format != internalformat) { |
| 4658 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ormat != internalformat"); | 4602 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ormat != internalformat"); |
| 4659 return false; | 4603 return false; |
| 4660 } | 4604 } |
| 4661 | 4605 |
| 4662 if (border) { | 4606 if (border) { |
| 4663 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "borde r != 0"); | 4607 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "borde r != 0"); |
| 4664 return false; | 4608 return false; |
| 4665 } | 4609 } |
| 4666 | 4610 |
| 4667 return true; | 4611 return true; |
| 4668 } | 4612 } |
| 4669 | 4613 |
| 4670 bool WebGLRenderingContext::validateTexFuncData(const char* functionName, GC3Din t level, | 4614 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GC 3Dint level, |
| 4671 GC3Dsizei width, GC3Dsizei heigh t, | 4615 GC3Dsizei width, GC3Dsizei height, |
| 4672 GC3Denum format, GC3Denum type, | 4616 GC3Denum format, GC3Denum type, |
| 4673 ArrayBufferView* pixels, | 4617 ArrayBufferView* pixels, |
| 4674 NullDisposition disposition) | 4618 NullDisposition disposition) |
| 4675 { | 4619 { |
| 4676 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 4620 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
| 4677 if (!pixels) { | 4621 if (!pixels) { |
| 4678 if (disposition == NullAllowed) | 4622 if (disposition == NullAllowed) |
| 4679 return true; | 4623 return true; |
| 4680 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pi xels"); | 4624 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pi xels"); |
| 4681 return false; | 4625 return false; |
| 4682 } | 4626 } |
| 4683 | 4627 |
| 4684 if (!validateTexFuncFormatAndType(functionName, format, type, level)) | 4628 if (!validateTexFuncFormatAndType(functionName, format, type, level)) |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 4712 // OES_texture_half_float is enabled. | 4656 // OES_texture_half_float is enabled. |
| 4713 if (pixels) { | 4657 if (pixels) { |
| 4714 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type HALF_FLOAT_OES but ArrayBufferView is not NULL"); | 4658 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type HALF_FLOAT_OES but ArrayBufferView is not NULL"); |
| 4715 return false; | 4659 return false; |
| 4716 } | 4660 } |
| 4717 break; | 4661 break; |
| 4718 default: | 4662 default: |
| 4719 ASSERT_NOT_REACHED(); | 4663 ASSERT_NOT_REACHED(); |
| 4720 } | 4664 } |
| 4721 | 4665 |
| 4722 unsigned int totalBytesRequired; | 4666 unsigned totalBytesRequired; |
| 4723 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_unpackAlignment, &totalBytesRequired, 0); | 4667 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_unpackAlignment, &totalBytesRequired, 0); |
| 4724 if (error != GraphicsContext3D::NO_ERROR) { | 4668 if (error != GraphicsContext3D::NO_ERROR) { |
| 4725 synthesizeGLError(error, functionName, "invalid texture dimensions"); | 4669 synthesizeGLError(error, functionName, "invalid texture dimensions"); |
| 4726 return false; | 4670 return false; |
| 4727 } | 4671 } |
| 4728 if (pixels->byteLength() < totalBytesRequired) { | 4672 if (pixels->byteLength() < totalBytesRequired) { |
| 4729 if (m_unpackAlignment != 1) { | 4673 if (m_unpackAlignment != 1) { |
| 4730 error = m_context->computeImageSizeInBytes(format, type, width, height , 1, &totalBytesRequired, 0); | 4674 error = m_context->computeImageSizeInBytes(format, type, width, heig ht, 1, &totalBytesRequired, 0); |
| 4731 if (pixels->byteLength() == totalBytesRequired) { | 4675 if (pixels->byteLength() == totalBytesRequired) { |
| 4732 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "ArrayBufferView not big enough for request with UNPACK_ALIGNMENT > 1"); | 4676 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, function Name, "ArrayBufferView not big enough for request with UNPACK_ALIGNMENT > 1"); |
| 4733 return false; | 4677 return false; |
| 4734 } | 4678 } |
| 4735 } | 4679 } |
| 4736 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "A rrayBufferView not big enough for request"); | 4680 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "A rrayBufferView not big enough for request"); |
| 4737 return false; | 4681 return false; |
| 4738 } | 4682 } |
| 4739 return true; | 4683 return true; |
| 4740 } | 4684 } |
| 4741 | 4685 |
| 4742 bool WebGLRenderingContext::validateCompressedTexFormat(GC3Denum format) | 4686 bool WebGLRenderingContextBase::validateCompressedTexFormat(GC3Denum format) |
| 4743 { | 4687 { |
| 4744 return m_compressedTextureFormats.contains(format); | 4688 return m_compressedTextureFormats.contains(format); |
| 4745 } | 4689 } |
| 4746 | 4690 |
| 4747 bool WebGLRenderingContext::validateCompressedTexFuncData(const char* functionNa me, | 4691 bool WebGLRenderingContextBase::validateCompressedTexFuncData(const char* functi onName, |
| 4748 GC3Dsizei width, GC3Ds izei height, | 4692 GC3Dsizei width, GC3Dsizei height, |
| 4749 GC3Denum format, Array BufferView* pixels) | 4693 GC3Denum format, ArrayBufferView* pixels) |
| 4750 { | 4694 { |
| 4751 if (!pixels) { | 4695 if (!pixels) { |
| 4752 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pi xels"); | 4696 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pi xels"); |
| 4753 return false; | 4697 return false; |
| 4754 } | 4698 } |
| 4755 if (width < 0 || height < 0) { | 4699 if (width < 0 || height < 0) { |
| 4756 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); | 4700 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); |
| 4757 return false; | 4701 return false; |
| 4758 } | 4702 } |
| 4759 | 4703 |
| 4760 unsigned int bytesRequired = 0; | 4704 unsigned bytesRequired = 0; |
| 4761 | 4705 |
| 4762 switch (format) { | 4706 switch (format) { |
| 4763 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: | 4707 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 4764 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: | 4708 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 4765 { | 4709 { |
| 4766 const int kBlockWidth = 4; | 4710 const int kBlockWidth = 4; |
| 4767 const int kBlockHeight = 4; | 4711 const int kBlockHeight = 4; |
| 4768 const int kBlockSize = 8; | 4712 const int kBlockSize = 8; |
| 4769 int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth; | 4713 int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth; |
| 4770 int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight; | 4714 int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4812 } | 4756 } |
| 4813 | 4757 |
| 4814 if (pixels->byteLength() != bytesRequired) { | 4758 if (pixels->byteLength() != bytesRequired) { |
| 4815 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "lengt h of ArrayBufferView is not correct for dimensions"); | 4759 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "lengt h of ArrayBufferView is not correct for dimensions"); |
| 4816 return false; | 4760 return false; |
| 4817 } | 4761 } |
| 4818 | 4762 |
| 4819 return true; | 4763 return true; |
| 4820 } | 4764 } |
| 4821 | 4765 |
| 4822 bool WebGLRenderingContext::validateCompressedTexDimensions(const char* function Name, TexFuncValidationFunctionType functionType, GC3Denum target, GC3Dint level , GC3Dsizei width, GC3Dsizei height, GC3Denum format) | 4766 bool WebGLRenderingContextBase::validateCompressedTexDimensions(const char* func tionName, TexFuncValidationFunctionType functionType, GC3Denum target, GC3Dint l evel, GC3Dsizei width, GC3Dsizei height, GC3Denum format) |
| 4823 { | 4767 { |
| 4824 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) | 4768 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) |
| 4825 return false; | 4769 return false; |
| 4826 | 4770 |
| 4827 switch (format) { | 4771 switch (format) { |
| 4828 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: | 4772 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 4829 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: | 4773 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 4830 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: | 4774 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: |
| 4831 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 4775 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
| 4832 const int kBlockWidth = 4; | 4776 const int kBlockWidth = 4; |
| 4833 const int kBlockHeight = 4; | 4777 const int kBlockHeight = 4; |
| 4834 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth); | 4778 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth); |
| 4835 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight); | 4779 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight); |
| 4836 if (!widthValid || !heightValid) { | 4780 if (!widthValid || !heightValid) { |
| 4837 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "width or height invalid for level"); | 4781 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "width or height invalid for level"); |
| 4838 return false; | 4782 return false; |
| 4839 } | 4783 } |
| 4840 return true; | 4784 return true; |
| 4841 } | 4785 } |
| 4842 default: | 4786 default: |
| 4843 return false; | 4787 return false; |
| 4844 } | 4788 } |
| 4845 } | 4789 } |
| 4846 | 4790 |
| 4847 bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* funct ionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, | 4791 bool WebGLRenderingContextBase::validateCompressedTexSubDimensions(const char* f unctionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, |
| 4848 GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex) | 4792 GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex) |
| 4849 { | 4793 { |
| 4850 if (xoffset < 0 || yoffset < 0) { | 4794 if (xoffset < 0 || yoffset < 0) { |
| 4851 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "xoffset or yoffset < 0"); | 4795 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "xoffs et or yoffset < 0"); |
| 4852 return false; | 4796 return false; |
| 4853 } | 4797 } |
| 4854 | 4798 |
| 4855 switch (format) { | 4799 switch (format) { |
| 4856 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: | 4800 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 4857 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: | 4801 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 4858 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: | 4802 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: |
| 4859 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 4803 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
| 4860 const int kBlockWidth = 4; | 4804 const int kBlockWidth = 4; |
| 4861 const int kBlockHeight = 4; | 4805 const int kBlockHeight = 4; |
| 4862 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 4806 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
| 4863 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "xoffset or yoffset not multiple of 4"); | 4807 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "xoffset or yoffset not multiple of 4"); |
| 4864 return false; | 4808 return false; |
| 4865 } | 4809 } |
| 4866 if (width - xoffset > tex->getWidth(target, level) | 4810 if (width - xoffset > tex->getWidth(target, level) |
| 4867 || height - yoffset > tex->getHeight(target, level)) { | 4811 || height - yoffset > tex->getHeight(target, level)) { |
| 4868 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "dimensions out of range"); | 4812 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "dimensions out of range"); |
| 4869 return false; | 4813 return false; |
| 4870 } | 4814 } |
| 4871 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); | 4815 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); |
| 4872 } | 4816 } |
| 4873 default: | 4817 default: |
| 4874 return false; | 4818 return false; |
| 4875 } | 4819 } |
| 4876 } | 4820 } |
| 4877 | 4821 |
| 4878 bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode) | 4822 bool WebGLRenderingContextBase::validateDrawMode(const char* functionName, GC3De num mode) |
| 4879 { | 4823 { |
| 4880 switch (mode) { | 4824 switch (mode) { |
| 4881 case GraphicsContext3D::POINTS: | 4825 case GraphicsContext3D::POINTS: |
| 4882 case GraphicsContext3D::LINE_STRIP: | 4826 case GraphicsContext3D::LINE_STRIP: |
| 4883 case GraphicsContext3D::LINE_LOOP: | 4827 case GraphicsContext3D::LINE_LOOP: |
| 4884 case GraphicsContext3D::LINES: | 4828 case GraphicsContext3D::LINES: |
| 4885 case GraphicsContext3D::TRIANGLE_STRIP: | 4829 case GraphicsContext3D::TRIANGLE_STRIP: |
| 4886 case GraphicsContext3D::TRIANGLE_FAN: | 4830 case GraphicsContext3D::TRIANGLE_FAN: |
| 4887 case GraphicsContext3D::TRIANGLES: | 4831 case GraphicsContext3D::TRIANGLES: |
| 4888 return true; | 4832 return true; |
| 4889 default: | 4833 default: |
| 4890 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d draw mode"); | 4834 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d draw mode"); |
| 4891 return false; | 4835 return false; |
| 4892 } | 4836 } |
| 4893 } | 4837 } |
| 4894 | 4838 |
| 4895 bool WebGLRenderingContext::validateStencilSettings(const char* functionName) | 4839 bool WebGLRenderingContextBase::validateStencilSettings(const char* functionName ) |
| 4896 { | 4840 { |
| 4897 if (m_stencilMask != m_stencilMaskBack || m_stencilFuncRef != m_stencilFuncR efBack || m_stencilFuncMask != m_stencilFuncMaskBack) { | 4841 if (m_stencilMask != m_stencilMaskBack || m_stencilFuncRef != m_stencilFuncR efBack || m_stencilFuncMask != m_stencilFuncMaskBack) { |
| 4898 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ront and back stencils settings do not match"); | 4842 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ront and back stencils settings do not match"); |
| 4899 return false; | 4843 return false; |
| 4900 } | 4844 } |
| 4901 return true; | 4845 return true; |
| 4902 } | 4846 } |
| 4903 | 4847 |
| 4904 bool WebGLRenderingContext::validateStencilOrDepthFunc(const char* functionName, GC3Denum func) | 4848 bool WebGLRenderingContextBase::validateStencilOrDepthFunc(const char* functionN ame, GC3Denum func) |
| 4905 { | 4849 { |
| 4906 switch (func) { | 4850 switch (func) { |
| 4907 case GraphicsContext3D::NEVER: | 4851 case GraphicsContext3D::NEVER: |
| 4908 case GraphicsContext3D::LESS: | 4852 case GraphicsContext3D::LESS: |
| 4909 case GraphicsContext3D::LEQUAL: | 4853 case GraphicsContext3D::LEQUAL: |
| 4910 case GraphicsContext3D::GREATER: | 4854 case GraphicsContext3D::GREATER: |
| 4911 case GraphicsContext3D::GEQUAL: | 4855 case GraphicsContext3D::GEQUAL: |
| 4912 case GraphicsContext3D::EQUAL: | 4856 case GraphicsContext3D::EQUAL: |
| 4913 case GraphicsContext3D::NOTEQUAL: | 4857 case GraphicsContext3D::NOTEQUAL: |
| 4914 case GraphicsContext3D::ALWAYS: | 4858 case GraphicsContext3D::ALWAYS: |
| 4915 return true; | 4859 return true; |
| 4916 default: | 4860 default: |
| 4917 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d function"); | 4861 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d function"); |
| 4918 return false; | 4862 return false; |
| 4919 } | 4863 } |
| 4920 } | 4864 } |
| 4921 | 4865 |
| 4922 void WebGLRenderingContext::printGLErrorToConsole(const String& message) | 4866 void WebGLRenderingContextBase::printGLErrorToConsole(const String& message) |
| 4923 { | 4867 { |
| 4924 if (!m_numGLErrorsToConsoleAllowed) | 4868 if (!m_numGLErrorsToConsoleAllowed) |
| 4925 return; | 4869 return; |
| 4926 | 4870 |
| 4927 --m_numGLErrorsToConsoleAllowed; | 4871 --m_numGLErrorsToConsoleAllowed; |
| 4928 printWarningToConsole(message); | 4872 printWarningToConsole(message); |
| 4929 | 4873 |
| 4930 if (!m_numGLErrorsToConsoleAllowed) | 4874 if (!m_numGLErrorsToConsoleAllowed) |
| 4931 printWarningToConsole("WebGL: too many errors, no more errors will be re ported to the console for this context."); | 4875 printWarningToConsole("WebGL: too many errors, no more errors will be re ported to the console for this context."); |
| 4932 | 4876 |
| 4933 return; | 4877 return; |
| 4934 } | 4878 } |
| 4935 | 4879 |
| 4936 void WebGLRenderingContext::printWarningToConsole(const String& message) | 4880 void WebGLRenderingContextBase::printWarningToConsole(const String& message) |
| 4937 { | 4881 { |
| 4938 if (!canvas()) | 4882 if (!canvas()) |
| 4939 return; | 4883 return; |
| 4940 canvas()->document().addConsoleMessage(RenderingMessageSource, WarningMessag eLevel, message); | 4884 canvas()->document().addConsoleMessage(RenderingMessageSource, WarningMessag eLevel, message); |
| 4941 } | 4885 } |
| 4942 | 4886 |
| 4943 bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functi onName, GC3Denum target, GC3Denum attachment) | 4887 bool WebGLRenderingContextBase::validateFramebufferFuncParameters(const char* fu nctionName, GC3Denum target, GC3Denum attachment) |
| 4944 { | 4888 { |
| 4945 if (target != GraphicsContext3D::FRAMEBUFFER) { | 4889 if (target != GraphicsContext3D::FRAMEBUFFER) { |
| 4946 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); | 4890 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); |
| 4947 return false; | 4891 return false; |
| 4948 } | 4892 } |
| 4949 switch (attachment) { | 4893 switch (attachment) { |
| 4950 case GraphicsContext3D::COLOR_ATTACHMENT0: | 4894 case GraphicsContext3D::COLOR_ATTACHMENT0: |
| 4951 case GraphicsContext3D::DEPTH_ATTACHMENT: | 4895 case GraphicsContext3D::DEPTH_ATTACHMENT: |
| 4952 case GraphicsContext3D::STENCIL_ATTACHMENT: | 4896 case GraphicsContext3D::STENCIL_ATTACHMENT: |
| 4953 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: | 4897 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: |
| 4954 break; | 4898 break; |
| 4955 default: | 4899 default: |
| 4956 if (m_webglDrawBuffers | 4900 if (extensionEnabled(WebGLDrawBuffersName) |
| 4957 && attachment > GraphicsContext3D::COLOR_ATTACHMENT0 | 4901 && attachment > GraphicsContext3D::COLOR_ATTACHMENT0 |
| 4958 && attachment < static_cast<GC3Denum>(GraphicsContext3D::COLOR_ATTAC HMENT0 + getMaxColorAttachments())) | 4902 && attachment < static_cast<GC3Denum>(GraphicsContext3D::COLOR_ATTAC HMENT0 + getMaxColorAttachments())) |
| 4959 break; | 4903 break; |
| 4960 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d attachment"); | 4904 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d attachment"); |
| 4961 return false; | 4905 return false; |
| 4962 } | 4906 } |
| 4963 return true; | 4907 return true; |
| 4964 } | 4908 } |
| 4965 | 4909 |
| 4966 bool WebGLRenderingContext::validateBlendEquation(const char* functionName, GC3D enum mode) | 4910 bool WebGLRenderingContextBase::validateBlendEquation(const char* functionName, GC3Denum mode) |
| 4967 { | 4911 { |
| 4968 switch (mode) { | 4912 switch (mode) { |
| 4969 case GraphicsContext3D::FUNC_ADD: | 4913 case GraphicsContext3D::FUNC_ADD: |
| 4970 case GraphicsContext3D::FUNC_SUBTRACT: | 4914 case GraphicsContext3D::FUNC_SUBTRACT: |
| 4971 case GraphicsContext3D::FUNC_REVERSE_SUBTRACT: | 4915 case GraphicsContext3D::FUNC_REVERSE_SUBTRACT: |
| 4972 return true; | 4916 return true; |
| 4973 default: | 4917 default: |
| 4974 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d mode"); | 4918 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d mode"); |
| 4975 return false; | 4919 return false; |
| 4976 } | 4920 } |
| 4977 } | 4921 } |
| 4978 | 4922 |
| 4979 bool WebGLRenderingContext::validateBlendFuncFactors(const char* functionName, G C3Denum src, GC3Denum dst) | 4923 bool WebGLRenderingContextBase::validateBlendFuncFactors(const char* functionNam e, GC3Denum src, GC3Denum dst) |
| 4980 { | 4924 { |
| 4981 if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D:: ONE_MINUS_CONSTANT_COLOR) | 4925 if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D:: ONE_MINUS_CONSTANT_COLOR) |
| 4982 && (dst == GraphicsContext3D::CONSTANT_ALPHA || dst == GraphicsContext3 D::ONE_MINUS_CONSTANT_ALPHA)) | 4926 && (dst == GraphicsContext3D::CONSTANT_ALPHA || dst == GraphicsContext3D ::ONE_MINUS_CONSTANT_ALPHA)) |
| 4983 || ((dst == GraphicsContext3D::CONSTANT_COLOR || dst == GraphicsContext3 D::ONE_MINUS_CONSTANT_COLOR) | 4927 || ((dst == GraphicsContext3D::CONSTANT_COLOR || dst == GraphicsContext3 D::ONE_MINUS_CONSTANT_COLOR) |
| 4984 && (src == GraphicsContext3D::CONSTANT_ALPHA || src == GraphicsConte xt3D::ONE_MINUS_CONSTANT_ALPHA))) { | 4928 && (src == GraphicsContext3D::CONSTANT_ALPHA || src == GraphicsConte xt3D::ONE_MINUS_CONSTANT_ALPHA))) { |
| 4985 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "i ncompatible src and dst"); | 4929 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "i ncompatible src and dst"); |
| 4986 return false; | 4930 return false; |
| 4987 } | 4931 } |
| 4988 return true; | 4932 return true; |
| 4989 } | 4933 } |
| 4990 | 4934 |
| 4991 bool WebGLRenderingContext::validateCapability(const char* functionName, GC3Denu m cap) | 4935 bool WebGLRenderingContextBase::validateCapability(const char* functionName, GC3 Denum cap) |
| 4992 { | 4936 { |
| 4993 switch (cap) { | 4937 switch (cap) { |
| 4994 case GraphicsContext3D::BLEND: | 4938 case GraphicsContext3D::BLEND: |
| 4995 case GraphicsContext3D::CULL_FACE: | 4939 case GraphicsContext3D::CULL_FACE: |
| 4996 case GraphicsContext3D::DEPTH_TEST: | 4940 case GraphicsContext3D::DEPTH_TEST: |
| 4997 case GraphicsContext3D::DITHER: | 4941 case GraphicsContext3D::DITHER: |
| 4998 case GraphicsContext3D::POLYGON_OFFSET_FILL: | 4942 case GraphicsContext3D::POLYGON_OFFSET_FILL: |
| 4999 case GraphicsContext3D::SAMPLE_ALPHA_TO_COVERAGE: | 4943 case GraphicsContext3D::SAMPLE_ALPHA_TO_COVERAGE: |
| 5000 case GraphicsContext3D::SAMPLE_COVERAGE: | 4944 case GraphicsContext3D::SAMPLE_COVERAGE: |
| 5001 case GraphicsContext3D::SCISSOR_TEST: | 4945 case GraphicsContext3D::SCISSOR_TEST: |
| 5002 case GraphicsContext3D::STENCIL_TEST: | 4946 case GraphicsContext3D::STENCIL_TEST: |
| 5003 return true; | 4947 return true; |
| 5004 default: | 4948 default: |
| 5005 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d capability"); | 4949 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d capability"); |
| 5006 return false; | 4950 return false; |
| 5007 } | 4951 } |
| 5008 } | 4952 } |
| 5009 | 4953 |
| 5010 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize ) | 4954 bool WebGLRenderingContextBase::validateUniformParameters(const char* functionNa me, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMin Size) |
| 5011 { | 4955 { |
| 5012 if (!v) { | 4956 if (!v) { |
| 5013 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); | 4957 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); |
| 5014 return false; | 4958 return false; |
| 5015 } | 4959 } |
| 5016 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); | 4960 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); |
| 5017 } | 4961 } |
| 5018 | 4962 |
| 5019 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize) | 4963 bool WebGLRenderingContextBase::validateUniformParameters(const char* functionNa me, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSi ze) |
| 5020 { | 4964 { |
| 5021 if (!v) { | 4965 if (!v) { |
| 5022 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); | 4966 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); |
| 5023 return false; | 4967 return false; |
| 5024 } | 4968 } |
| 5025 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); | 4969 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); |
| 5026 } | 4970 } |
| 5027 | 4971 |
| 5028 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei require dMinSize) | 4972 bool WebGLRenderingContextBase::validateUniformParameters(const char* functionNa me, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei req uiredMinSize) |
| 5029 { | 4973 { |
| 5030 return validateUniformMatrixParameters(functionName, location, false, v, siz e, requiredMinSize); | 4974 return validateUniformMatrixParameters(functionName, location, false, v, siz e, requiredMinSize); |
| 5031 } | 4975 } |
| 5032 | 4976 |
| 5033 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize) | 4977 bool WebGLRenderingContextBase::validateUniformMatrixParameters(const char* func tionName, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Ar ray* v, GC3Dsizei requiredMinSize) |
| 5034 { | 4978 { |
| 5035 if (!v) { | 4979 if (!v) { |
| 5036 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); | 4980 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); |
| 5037 return false; | 4981 return false; |
| 5038 } | 4982 } |
| 5039 return validateUniformMatrixParameters(functionName, location, transpose, v- >data(), v->length(), requiredMinSize); | 4983 return validateUniformMatrixParameters(functionName, location, transpose, v- >data(), v->length(), requiredMinSize); |
| 5040 } | 4984 } |
| 5041 | 4985 |
| 5042 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3D sizei size, GC3Dsizei requiredMinSize) | 4986 bool WebGLRenderingContextBase::validateUniformMatrixParameters(const char* func tionName, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize) |
| 5043 { | 4987 { |
| 5044 if (!location) | 4988 if (!location) |
| 5045 return false; | 4989 return false; |
| 5046 if (location->program() != m_currentProgram) { | 4990 if (location->program() != m_currentProgram) { |
| 5047 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "l ocation is not from current program"); | 4991 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "l ocation is not from current program"); |
| 5048 return false; | 4992 return false; |
| 5049 } | 4993 } |
| 5050 if (!v) { | 4994 if (!v) { |
| 5051 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); | 4995 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); |
| 5052 return false; | 4996 return false; |
| 5053 } | 4997 } |
| 5054 if (transpose) { | 4998 if (transpose) { |
| 5055 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans pose not FALSE"); | 4999 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans pose not FALSE"); |
| 5056 return false; | 5000 return false; |
| 5057 } | 5001 } |
| 5058 if (size < requiredMinSize || (size % requiredMinSize)) { | 5002 if (size < requiredMinSize || (size % requiredMinSize)) { |
| 5059 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); | 5003 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); |
| 5060 return false; | 5004 return false; |
| 5061 } | 5005 } |
| 5062 return true; | 5006 return true; |
| 5063 } | 5007 } |
| 5064 | 5008 |
| 5065 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun ctionName, GC3Denum target, GC3Denum usage) | 5009 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage) |
| 5066 { | 5010 { |
| 5067 WebGLBuffer* buffer = 0; | 5011 WebGLBuffer* buffer = 0; |
| 5068 switch (target) { | 5012 switch (target) { |
| 5069 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER: | 5013 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER: |
| 5070 buffer = m_boundVertexArrayObject->getElementArrayBuffer().get(); | 5014 buffer = m_boundVertexArrayObject->getElementArrayBuffer().get(); |
| 5071 break; | 5015 break; |
| 5072 case GraphicsContext3D::ARRAY_BUFFER: | 5016 case GraphicsContext3D::ARRAY_BUFFER: |
| 5073 buffer = m_boundArrayBuffer.get(); | 5017 buffer = m_boundArrayBuffer.get(); |
| 5074 break; | 5018 break; |
| 5075 default: | 5019 default: |
| 5076 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); | 5020 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); |
| 5077 return 0; | 5021 return 0; |
| 5078 } | 5022 } |
| 5079 if (!buffer) { | 5023 if (!buffer) { |
| 5080 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o buffer"); | 5024 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o buffer"); |
| 5081 return 0; | 5025 return 0; |
| 5082 } | 5026 } |
| 5083 switch (usage) { | 5027 switch (usage) { |
| 5084 case GraphicsContext3D::STREAM_DRAW: | 5028 case GraphicsContext3D::STREAM_DRAW: |
| 5085 case GraphicsContext3D::STATIC_DRAW: | 5029 case GraphicsContext3D::STATIC_DRAW: |
| 5086 case GraphicsContext3D::DYNAMIC_DRAW: | 5030 case GraphicsContext3D::DYNAMIC_DRAW: |
| 5087 return buffer; | 5031 return buffer; |
| 5088 } | 5032 } |
| 5089 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us age"); | 5033 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us age"); |
| 5090 return 0; | 5034 return 0; |
| 5091 } | 5035 } |
| 5092 | 5036 |
| 5093 bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, H TMLImageElement* image, ExceptionState& es) | 5037 bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionNam e, HTMLImageElement* image, ExceptionState& es) |
| 5094 { | 5038 { |
| 5095 if (!image || !image->cachedImage()) { | 5039 if (!image || !image->cachedImage()) { |
| 5096 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no im age"); | 5040 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no im age"); |
| 5097 return false; | 5041 return false; |
| 5098 } | 5042 } |
| 5099 const KURL& url = image->cachedImage()->response().url(); | 5043 const KURL& url = image->cachedImage()->response().url(); |
| 5100 if (url.isNull() || url.isEmpty() || !url.isValid()) { | 5044 if (url.isNull() || url.isEmpty() || !url.isValid()) { |
| 5101 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id image"); | 5045 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id image"); |
| 5102 return false; | 5046 return false; |
| 5103 } | 5047 } |
| 5104 if (wouldTaintOrigin(image)) { | 5048 if (wouldTaintOrigin(image)) { |
| 5105 es.throwSecurityError(ExceptionMessages::failedToExecute(functionName, " WebGLRenderingContext", "the cross-origin image at " + url.elidedString() + " ma y not be loaded.")); | 5049 es.throwSecurityError(ExceptionMessages::failedToExecute(functionName, m _contextName, "the cross-origin image at " + url.elidedString() + " may not be l oaded.")); |
| 5106 return false; | 5050 return false; |
| 5107 } | 5051 } |
| 5108 return true; | 5052 return true; |
| 5109 } | 5053 } |
| 5110 | 5054 |
| 5111 bool WebGLRenderingContext::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas, ExceptionState& es) | 5055 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionNa me, HTMLCanvasElement* canvas, ExceptionState& es) |
| 5112 { | 5056 { |
| 5113 if (!canvas || !canvas->buffer()) { | 5057 if (!canvas || !canvas->buffer()) { |
| 5114 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ca nvas"); | 5058 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ca nvas"); |
| 5115 return false; | 5059 return false; |
| 5116 } | 5060 } |
| 5117 if (wouldTaintOrigin(canvas)) { | 5061 if (wouldTaintOrigin(canvas)) { |
| 5118 es.throwSecurityError(ExceptionMessages::failedToExecute(functionName, " WebGLRenderingContext", "tainted canvases may not be loded.")); | 5062 es.throwSecurityError(ExceptionMessages::failedToExecute(functionName, m _contextName, "tainted canvases may not be loded.")); |
| 5119 return false; | 5063 return false; |
| 5120 } | 5064 } |
| 5121 return true; | 5065 return true; |
| 5122 } | 5066 } |
| 5123 | 5067 |
| 5124 bool WebGLRenderingContext::validateHTMLVideoElement(const char* functionName, H TMLVideoElement* video, ExceptionState& es) | 5068 bool WebGLRenderingContextBase::validateHTMLVideoElement(const char* functionNam e, HTMLVideoElement* video, ExceptionState& es) |
| 5125 { | 5069 { |
| 5126 if (!video || !video->videoWidth() || !video->videoHeight()) { | 5070 if (!video || !video->videoWidth() || !video->videoHeight()) { |
| 5127 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no vi deo"); | 5071 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no vi deo"); |
| 5128 return false; | 5072 return false; |
| 5129 } | 5073 } |
| 5130 if (wouldTaintOrigin(video)) { | 5074 if (wouldTaintOrigin(video)) { |
| 5131 es.throwSecurityError(ExceptionMessages::failedToExecute(functionName, " WebGLRenderingContext", "the video element contains cross-origin data, and may n ot be loaded.")); | 5075 es.throwSecurityError(ExceptionMessages::failedToExecute(functionName, m _contextName, "the video element contains cross-origin data, and may not be load ed.")); |
| 5132 return false; | 5076 return false; |
| 5133 } | 5077 } |
| 5134 return true; | 5078 return true; |
| 5135 } | 5079 } |
| 5136 | 5080 |
| 5137 bool WebGLRenderingContext::validateDrawArrays(const char* functionName, GC3Denu m mode, GC3Dint first, GC3Dsizei count) | 5081 bool WebGLRenderingContextBase::validateDrawArrays(const char* functionName, GC3 Denum mode, GC3Dint first, GC3Dsizei count) |
| 5138 { | 5082 { |
| 5139 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5083 if (isContextLost() || !validateDrawMode(functionName, mode)) |
| 5140 return false; | 5084 return false; |
| 5141 | 5085 |
| 5142 if (!validateStencilSettings(functionName)) | 5086 if (!validateStencilSettings(functionName)) |
| 5143 return false; | 5087 return false; |
| 5144 | 5088 |
| 5145 if (first < 0 || count < 0) { | 5089 if (first < 0 || count < 0) { |
| 5146 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "first or count < 0"); | 5090 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "first or count < 0"); |
| 5147 return false; | 5091 return false; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 5159 | 5103 |
| 5160 const char* reason = "framebuffer incomplete"; | 5104 const char* reason = "framebuffer incomplete"; |
| 5161 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { | 5105 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { |
| 5162 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); | 5106 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); |
| 5163 return false; | 5107 return false; |
| 5164 } | 5108 } |
| 5165 | 5109 |
| 5166 return true; | 5110 return true; |
| 5167 } | 5111 } |
| 5168 | 5112 |
| 5169 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De num mode, GC3Dsizei count, GC3Denum type, long long offset) | 5113 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G C3Denum mode, GC3Dsizei count, GC3Denum type, long long offset) |
| 5170 { | 5114 { |
| 5171 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5115 if (isContextLost() || !validateDrawMode(functionName, mode)) |
| 5172 return false; | 5116 return false; |
| 5173 | 5117 |
| 5174 if (!validateStencilSettings(functionName)) | 5118 if (!validateStencilSettings(functionName)) |
| 5175 return false; | 5119 return false; |
| 5176 | 5120 |
| 5177 switch (type) { | 5121 switch (type) { |
| 5178 case GraphicsContext3D::UNSIGNED_BYTE: | 5122 case GraphicsContext3D::UNSIGNED_BYTE: |
| 5179 case GraphicsContext3D::UNSIGNED_SHORT: | 5123 case GraphicsContext3D::UNSIGNED_SHORT: |
| 5180 break; | 5124 break; |
| 5181 case GraphicsContext3D::UNSIGNED_INT: | 5125 case GraphicsContext3D::UNSIGNED_INT: |
| 5182 if (m_oesElementIndexUint) | 5126 if (extensionEnabled(OESElementIndexUintName)) |
|
bajones
2013/09/24 00:12:01
Lots of changes like this throughout. More verbose
| |
| 5183 break; | 5127 break; |
| 5184 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d type"); | 5128 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d type"); |
| 5185 return false; | 5129 return false; |
| 5186 default: | 5130 default: |
| 5187 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d type"); | 5131 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d type"); |
| 5188 return false; | 5132 return false; |
| 5189 } | 5133 } |
| 5190 | 5134 |
| 5191 if (count < 0 || offset < 0) { | 5135 if (count < 0 || offset < 0) { |
| 5192 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "count or offset < 0"); | 5136 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "count or offset < 0"); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 5211 const char* reason = "framebuffer incomplete"; | 5155 const char* reason = "framebuffer incomplete"; |
| 5212 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { | 5156 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { |
| 5213 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); | 5157 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); |
| 5214 return false; | 5158 return false; |
| 5215 } | 5159 } |
| 5216 | 5160 |
| 5217 return true; | 5161 return true; |
| 5218 } | 5162 } |
| 5219 | 5163 |
| 5220 // Helper function to validate draw*Instanced calls | 5164 // Helper function to validate draw*Instanced calls |
| 5221 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D sizei primcount) | 5165 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName, GC3Dsizei primcount) |
| 5222 { | 5166 { |
| 5223 if (primcount < 0) { | 5167 if (primcount < 0) { |
| 5224 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "primc ount < 0"); | 5168 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "primc ount < 0"); |
| 5225 return false; | 5169 return false; |
| 5226 } | 5170 } |
| 5227 | 5171 |
| 5228 // Ensure at least one enabled vertex attrib has a divisor of 0. | 5172 // Ensure at least one enabled vertex attrib has a divisor of 0. |
| 5229 for (unsigned i = 0; i < m_onePlusMaxEnabledAttribIndex; ++i) { | 5173 for (unsigned i = 0; i < m_onePlusMaxEnabledAttribIndex; ++i) { |
| 5230 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i); | 5174 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i); |
| 5231 if (state.enabled && !state.divisor) | 5175 if (state.enabled && !state.divisor) |
| 5232 return true; | 5176 return true; |
| 5233 } | 5177 } |
| 5234 | 5178 |
| 5235 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "at le ast one enabled attribute must have a divisor of 0"); | 5179 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "at le ast one enabled attribute must have a divisor of 0"); |
| 5236 return false; | 5180 return false; |
| 5237 } | 5181 } |
| 5238 | 5182 |
| 5239 void WebGLRenderingContext::vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfl oat v3) | 5183 void WebGLRenderingContextBase::vertexAttribfImpl(const char* functionName, GC3D uint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC 3Dfloat v3) |
| 5240 { | 5184 { |
| 5241 if (isContextLost()) | 5185 if (isContextLost()) |
| 5242 return; | 5186 return; |
| 5243 if (index >= m_maxVertexAttribs) { | 5187 if (index >= m_maxVertexAttribs) { |
| 5244 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range"); | 5188 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range"); |
| 5245 return; | 5189 return; |
| 5246 } | 5190 } |
| 5247 // In GL, we skip setting vertexAttrib0 values. | 5191 // In GL, we skip setting vertexAttrib0 values. |
| 5248 switch (expectedSize) { | 5192 switch (expectedSize) { |
| 5249 case 1: | 5193 case 1: |
| 5250 m_context->vertexAttrib1f(index, v0); | 5194 m_context->vertexAttrib1f(index, v0); |
| 5251 break; | 5195 break; |
| 5252 case 2: | 5196 case 2: |
| 5253 m_context->vertexAttrib2f(index, v0, v1); | 5197 m_context->vertexAttrib2f(index, v0, v1); |
| 5254 break; | 5198 break; |
| 5255 case 3: | 5199 case 3: |
| 5256 m_context->vertexAttrib3f(index, v0, v1, v2); | 5200 m_context->vertexAttrib3f(index, v0, v1, v2); |
| 5257 break; | 5201 break; |
| 5258 case 4: | 5202 case 4: |
| 5259 m_context->vertexAttrib4f(index, v0, v1, v2, v3); | 5203 m_context->vertexAttrib4f(index, v0, v1, v2, v3); |
| 5260 break; | 5204 break; |
| 5261 } | 5205 } |
| 5262 VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 5206 VertexAttribValue& attribValue = m_vertexAttribValue[index]; |
| 5263 attribValue.value[0] = v0; | 5207 attribValue.value[0] = v0; |
| 5264 attribValue.value[1] = v1; | 5208 attribValue.value[1] = v1; |
| 5265 attribValue.value[2] = v2; | 5209 attribValue.value[2] = v2; |
| 5266 attribValue.value[3] = v3; | 5210 attribValue.value[3] = v3; |
| 5267 } | 5211 } |
| 5268 | 5212 |
| 5269 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duin t index, Float32Array* v, GC3Dsizei expectedSize) | 5213 void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GC3 Duint index, Float32Array* v, GC3Dsizei expectedSize) |
| 5270 { | 5214 { |
| 5271 if (isContextLost()) | 5215 if (isContextLost()) |
| 5272 return; | 5216 return; |
| 5273 if (!v) { | 5217 if (!v) { |
| 5274 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); | 5218 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); |
| 5275 return; | 5219 return; |
| 5276 } | 5220 } |
| 5277 vertexAttribfvImpl(functionName, index, v->data(), v->length(), expectedSize ); | 5221 vertexAttribfvImpl(functionName, index, v->data(), v->length(), expectedSize ); |
| 5278 } | 5222 } |
| 5279 | 5223 |
| 5280 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duin t index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize) | 5224 void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GC3 Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize) |
| 5281 { | 5225 { |
| 5282 if (isContextLost()) | 5226 if (isContextLost()) |
| 5283 return; | 5227 return; |
| 5284 if (!v) { | 5228 if (!v) { |
| 5285 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); | 5229 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); |
| 5286 return; | 5230 return; |
| 5287 } | 5231 } |
| 5288 if (size < expectedSize) { | 5232 if (size < expectedSize) { |
| 5289 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); | 5233 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); |
| 5290 return; | 5234 return; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 5307 case 4: | 5251 case 4: |
| 5308 m_context->vertexAttrib4fv(index, v); | 5252 m_context->vertexAttrib4fv(index, v); |
| 5309 break; | 5253 break; |
| 5310 } | 5254 } |
| 5311 VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 5255 VertexAttribValue& attribValue = m_vertexAttribValue[index]; |
| 5312 attribValue.initValue(); | 5256 attribValue.initValue(); |
| 5313 for (int ii = 0; ii < expectedSize; ++ii) | 5257 for (int ii = 0; ii < expectedSize; ++ii) |
| 5314 attribValue.value[ii] = v[ii]; | 5258 attribValue.value[ii] = v[ii]; |
| 5315 } | 5259 } |
| 5316 | 5260 |
| 5317 void WebGLRenderingContext::dispatchContextLostEvent(Timer<WebGLRenderingContext >*) | 5261 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon textBase>*) |
| 5318 { | 5262 { |
| 5319 RefPtr<WebGLContextEvent> event = WebGLContextEvent::create(eventNames().web glcontextlostEvent, false, true, ""); | 5263 RefPtr<WebGLContextEvent> event = WebGLContextEvent::create(eventNames().web glcontextlostEvent, false, true, ""); |
| 5320 canvas()->dispatchEvent(event); | 5264 canvas()->dispatchEvent(event); |
| 5321 m_restoreAllowed = event->defaultPrevented(); | 5265 m_restoreAllowed = event->defaultPrevented(); |
| 5322 deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAll owed); | 5266 deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAll owed); |
| 5323 if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecove rSyntheticLostContext) && m_restoreAllowed) | 5267 if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecove rSyntheticLostContext) && m_restoreAllowed) |
| 5324 m_restoreTimer.startOneShot(0); | 5268 m_restoreTimer.startOneShot(0); |
| 5325 } | 5269 } |
| 5326 | 5270 |
| 5327 void WebGLRenderingContext::maybeRestoreContext(Timer<WebGLRenderingContext>*) | 5271 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB ase>*) |
| 5328 { | 5272 { |
| 5329 ASSERT(isContextLost()); | 5273 ASSERT(isContextLost()); |
| 5330 | 5274 |
| 5331 // The rendering context is not restored unless the default behavior of the | 5275 // The rendering context is not restored unless the default behavior of the |
| 5332 // webglcontextlost event was prevented earlier. | 5276 // webglcontextlost event was prevented earlier. |
| 5333 // | 5277 // |
| 5334 // Because of the way m_restoreTimer is set up for real vs. synthetic lost | 5278 // Because of the way m_restoreTimer is set up for real vs. synthetic lost |
| 5335 // context events, we don't have to worry about this test short-circuiting | 5279 // context events, we don't have to worry about this test short-circuiting |
| 5336 // the retry loop for real context lost events. | 5280 // the retry loop for real context lost events. |
| 5337 if (!m_restoreAllowed) | 5281 if (!m_restoreAllowed) |
| 5338 return; | 5282 return; |
| 5339 | 5283 |
| 5340 Frame* frame = canvas()->document().frame(); | 5284 Frame* frame = canvas()->document().frame(); |
| 5341 if (!frame) | 5285 if (!frame) |
| 5342 return; | 5286 return; |
| 5343 | 5287 |
| 5344 Settings* settings = frame->settings(); | 5288 Settings* settings = frame->settings(); |
| 5345 | 5289 |
| 5346 if (!frame->loader()->client()->allowWebGL(settings && settings->webGLEnable d())) | 5290 if (!frame->loader()->client()->allowWebGL(settings && settings->webGLEnable d())) |
| 5347 return; | 5291 return; |
| 5348 | 5292 |
| 5349 // Reset the context attributes back to the requested attributes and re-appl y restrictions | 5293 // Reset the context attributes back to the requested attributes and re-appl y restrictions |
| 5350 m_attributes = adjustAttributes(m_requestedAttributes, settings); | 5294 m_attributes = WebGLRenderingContextBase::adjustAttributes(m_requestedAttrib utes, settings); |
| 5351 | 5295 |
| 5352 RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes)); | 5296 RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes)); |
| 5353 | 5297 |
| 5354 if (!context) { | 5298 if (!context) { |
| 5355 if (m_contextLostMode == RealLostContext) | 5299 if (m_contextLostMode == RealLostContext) { |
| 5356 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); | 5300 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); |
| 5357 else | 5301 } else { |
| 5358 // This likely shouldn't happen but is the best way to report it to the WebGL app. | 5302 // This likely shouldn't happen but is the best way to report it to the WebGL app. |
| 5359 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "", "error r estoring context"); | 5303 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "", "error r estoring context"); |
| 5304 } | |
| 5360 return; | 5305 return; |
| 5361 } | 5306 } |
| 5362 | 5307 |
| 5363 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); | 5308 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); |
| 5364 | 5309 |
| 5365 // Construct a new drawing buffer with the new GraphicsContext3D. | 5310 // Construct a new drawing buffer with the new GraphicsContext3D. |
| 5366 m_drawingBuffer->releaseResources(); | 5311 m_drawingBuffer->releaseResources(); |
| 5367 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 5312 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 5368 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); | 5313 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); |
| 5369 | 5314 |
| 5370 if (m_drawingBuffer->isZeroSized()) | 5315 if (m_drawingBuffer->isZeroSized()) |
| 5371 return; | 5316 return; |
| 5372 | 5317 |
| 5373 m_drawingBuffer->bind(); | 5318 m_drawingBuffer->bind(); |
| 5374 | 5319 |
| 5375 lost_context_errors_.clear(); | 5320 m_lostContextErrors.clear(); |
| 5376 | 5321 |
| 5377 m_context = context; | 5322 m_context = context; |
| 5378 m_contextLost = false; | 5323 m_contextLost = false; |
| 5379 | 5324 |
| 5380 setupFlags(); | 5325 setupFlags(); |
| 5381 initializeNewContext(); | 5326 initializeNewContext(); |
| 5382 canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextr estoredEvent, false, true, "")); | 5327 canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextr estoredEvent, false, true, "")); |
| 5383 } | 5328 } |
| 5384 | 5329 |
| 5385 String WebGLRenderingContext::ensureNotNull(const String& text) const | 5330 String WebGLRenderingContextBase::ensureNotNull(const String& text) const |
| 5386 { | 5331 { |
| 5387 if (text.isNull()) | 5332 if (text.isNull()) |
| 5388 return WTF::emptyString(); | 5333 return WTF::emptyString(); |
| 5389 return text; | 5334 return text; |
| 5390 } | 5335 } |
| 5391 | 5336 |
| 5392 WebGLRenderingContext::LRUImageBufferCache::LRUImageBufferCache(int capacity) | 5337 WebGLRenderingContextBase::LRUImageBufferCache::LRUImageBufferCache(int capacity ) |
| 5393 : m_buffers(adoptArrayPtr(new OwnPtr<ImageBuffer>[capacity])) | 5338 : m_buffers(adoptArrayPtr(new OwnPtr<ImageBuffer>[capacity])) |
| 5394 , m_capacity(capacity) | 5339 , m_capacity(capacity) |
| 5395 { | 5340 { |
| 5396 } | 5341 } |
| 5397 | 5342 |
| 5398 ImageBuffer* WebGLRenderingContext::LRUImageBufferCache::imageBuffer(const IntSi ze& size) | 5343 ImageBuffer* WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer(const I ntSize& size) |
| 5399 { | 5344 { |
| 5400 int i; | 5345 int i; |
| 5401 for (i = 0; i < m_capacity; ++i) { | 5346 for (i = 0; i < m_capacity; ++i) { |
| 5402 ImageBuffer* buf = m_buffers[i].get(); | 5347 ImageBuffer* buf = m_buffers[i].get(); |
| 5403 if (!buf) | 5348 if (!buf) |
| 5404 break; | 5349 break; |
| 5405 if (buf->logicalSize() != size) | 5350 if (buf->logicalSize() != size) |
| 5406 continue; | 5351 continue; |
| 5407 bubbleToFront(i); | 5352 bubbleToFront(i); |
| 5408 return buf; | 5353 return buf; |
| 5409 } | 5354 } |
| 5410 | 5355 |
| 5411 OwnPtr<ImageBuffer> temp = ImageBuffer::create(size, 1); | 5356 OwnPtr<ImageBuffer> temp = ImageBuffer::create(size, 1); |
| 5412 if (!temp) | 5357 if (!temp) |
| 5413 return 0; | 5358 return 0; |
| 5414 i = std::min(m_capacity - 1, i); | 5359 i = std::min(m_capacity - 1, i); |
| 5415 m_buffers[i] = temp.release(); | 5360 m_buffers[i] = temp.release(); |
| 5416 | 5361 |
| 5417 ImageBuffer* buf = m_buffers[i].get(); | 5362 ImageBuffer* buf = m_buffers[i].get(); |
| 5418 bubbleToFront(i); | 5363 bubbleToFront(i); |
| 5419 return buf; | 5364 return buf; |
| 5420 } | 5365 } |
| 5421 | 5366 |
| 5422 void WebGLRenderingContext::LRUImageBufferCache::bubbleToFront(int idx) | 5367 void WebGLRenderingContextBase::LRUImageBufferCache::bubbleToFront(int idx) |
| 5423 { | 5368 { |
| 5424 for (int i = idx; i > 0; --i) | 5369 for (int i = idx; i > 0; --i) |
| 5425 m_buffers[i].swap(m_buffers[i-1]); | 5370 m_buffers[i].swap(m_buffers[i-1]); |
| 5426 } | 5371 } |
| 5427 | 5372 |
| 5428 namespace { | 5373 namespace { |
| 5429 | 5374 |
| 5430 String GetErrorString(GC3Denum error) | 5375 String GetErrorString(GC3Denum error) |
| 5431 { | 5376 { |
| 5432 switch (error) { | 5377 switch (error) { |
| 5433 case GraphicsContext3D::INVALID_ENUM: | 5378 case GraphicsContext3D::INVALID_ENUM: |
| 5434 return "INVALID_ENUM"; | 5379 return "INVALID_ENUM"; |
| 5435 case GraphicsContext3D::INVALID_VALUE: | 5380 case GraphicsContext3D::INVALID_VALUE: |
| 5436 return "INVALID_VALUE"; | 5381 return "INVALID_VALUE"; |
| 5437 case GraphicsContext3D::INVALID_OPERATION: | 5382 case GraphicsContext3D::INVALID_OPERATION: |
| 5438 return "INVALID_OPERATION"; | 5383 return "INVALID_OPERATION"; |
| 5439 case GraphicsContext3D::OUT_OF_MEMORY: | 5384 case GraphicsContext3D::OUT_OF_MEMORY: |
| 5440 return "OUT_OF_MEMORY"; | 5385 return "OUT_OF_MEMORY"; |
| 5441 case GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION: | 5386 case GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION: |
| 5442 return "INVALID_FRAMEBUFFER_OPERATION"; | 5387 return "INVALID_FRAMEBUFFER_OPERATION"; |
| 5443 case GraphicsContext3D::CONTEXT_LOST_WEBGL: | 5388 case GraphicsContext3D::CONTEXT_LOST_WEBGL: |
| 5444 return "CONTEXT_LOST_WEBGL"; | 5389 return "CONTEXT_LOST_WEBGL"; |
| 5445 default: | 5390 default: |
| 5446 return String::format("WebGL ERROR(0x%04X)", error); | 5391 return String::format("WebGL ERROR(0x%04X)", error); |
| 5447 } | 5392 } |
| 5448 } | 5393 } |
| 5449 | 5394 |
| 5450 } // namespace anonymous | 5395 } // namespace anonymous |
| 5451 | 5396 |
| 5452 void WebGLRenderingContext::synthesizeGLError(GC3Denum error, const char* functi onName, const char* description, ConsoleDisplayPreference display) | 5397 void WebGLRenderingContextBase::synthesizeGLError(GC3Denum error, const char* fu nctionName, const char* description, ConsoleDisplayPreference display) |
| 5453 { | 5398 { |
| 5454 String errorType = GetErrorString(error); | 5399 String errorType = GetErrorString(error); |
| 5455 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { | 5400 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { |
| 5456 String message = String("WebGL: ") + errorType + ": " + String(function Name) + ": " + String(description); | 5401 String message = String("WebGL: ") + errorType + ": " + String(function Name) + ": " + String(description); |
| 5457 printGLErrorToConsole(message); | 5402 printGLErrorToConsole(message); |
| 5458 } | 5403 } |
| 5459 if (!isContextLost()) | 5404 if (!isContextLost()) { |
| 5460 m_context->synthesizeGLError(error); | 5405 m_context->synthesizeGLError(error); |
| 5461 else { | 5406 } else { |
| 5462 if (lost_context_errors_.find(error) == WTF::notFound) | 5407 if (m_lostContextErrors.find(error) == WTF::notFound) |
| 5463 lost_context_errors_.append(error); | 5408 m_lostContextErrors.append(error); |
| 5464 } | 5409 } |
| 5465 InspectorInstrumentation::didFireWebGLError(canvas(), errorType); | 5410 InspectorInstrumentation::didFireWebGLError(canvas(), errorType); |
| 5466 } | 5411 } |
| 5467 | 5412 |
| 5468 void WebGLRenderingContext::emitGLWarning(const char* functionName, const char* description) | 5413 void WebGLRenderingContextBase::emitGLWarning(const char* functionName, const ch ar* description) |
| 5469 { | 5414 { |
| 5470 if (m_synthesizedErrorsToConsole) { | 5415 if (m_synthesizedErrorsToConsole) { |
| 5471 String message = String("WebGL: ") + String(functionName) + ": " + Strin g(description); | 5416 String message = String("WebGL: ") + String(functionName) + ": " + Strin g(description); |
| 5472 printGLErrorToConsole(message); | 5417 printGLErrorToConsole(message); |
| 5473 } | 5418 } |
| 5474 InspectorInstrumentation::didFireWebGLWarning(canvas()); | 5419 InspectorInstrumentation::didFireWebGLWarning(canvas()); |
| 5475 } | 5420 } |
| 5476 | 5421 |
| 5477 void WebGLRenderingContext::applyStencilTest() | 5422 void WebGLRenderingContextBase::applyStencilTest() |
| 5478 { | 5423 { |
| 5479 bool haveStencilBuffer = false; | 5424 bool haveStencilBuffer = false; |
| 5480 | 5425 |
| 5481 if (m_framebufferBinding) | 5426 if (m_framebufferBinding) { |
| 5482 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); | 5427 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); |
| 5483 else { | 5428 } else { |
| 5484 RefPtr<WebGLContextAttributes> attributes = getContextAttributes(); | 5429 RefPtr<WebGLContextAttributes> attributes = getContextAttributes(); |
| 5485 haveStencilBuffer = attributes->stencil(); | 5430 haveStencilBuffer = attributes->stencil(); |
| 5486 } | 5431 } |
| 5487 enableOrDisable(GraphicsContext3D::STENCIL_TEST, | 5432 enableOrDisable(GraphicsContext3D::STENCIL_TEST, m_stencilEnabled && haveSte ncilBuffer); |
| 5488 m_stencilEnabled && haveStencilBuffer); | |
| 5489 } | 5433 } |
| 5490 | 5434 |
| 5491 void WebGLRenderingContext::enableOrDisable(GC3Denum capability, bool enable) | 5435 void WebGLRenderingContextBase::enableOrDisable(GC3Denum capability, bool enable ) |
| 5492 { | 5436 { |
| 5493 if (isContextLost()) | 5437 if (isContextLost()) |
| 5494 return; | 5438 return; |
| 5495 if (enable) | 5439 if (enable) |
| 5496 m_context->enable(capability); | 5440 m_context->enable(capability); |
| 5497 else | 5441 else |
| 5498 m_context->disable(capability); | 5442 m_context->disable(capability); |
| 5499 } | 5443 } |
| 5500 | 5444 |
| 5501 IntSize WebGLRenderingContext::clampedCanvasSize() | 5445 IntSize WebGLRenderingContextBase::clampedCanvasSize() |
| 5502 { | 5446 { |
| 5503 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), | 5447 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), clamp(canv as()->height(), 1, m_maxViewportDims[1])); |
| 5504 clamp(canvas()->height(), 1, m_maxViewportDims[1])); | |
| 5505 } | 5448 } |
| 5506 | 5449 |
| 5507 GC3Dint WebGLRenderingContext::getMaxDrawBuffers() | 5450 GC3Dint WebGLRenderingContextBase::getMaxDrawBuffers() |
| 5508 { | 5451 { |
| 5509 if (isContextLost() || !m_webglDrawBuffers) | 5452 if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) |
| 5510 return 0; | 5453 return 0; |
| 5511 if (!m_maxDrawBuffers) | 5454 if (!m_maxDrawBuffers) |
| 5512 m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuf fers); | 5455 m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuf fers); |
| 5513 if (!m_maxColorAttachments) | 5456 if (!m_maxColorAttachments) |
| 5514 m_context->getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &m_maxCo lorAttachments); | 5457 m_context->getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &m_maxCo lorAttachments); |
| 5515 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. | 5458 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. |
| 5516 return std::min(m_maxDrawBuffers, m_maxColorAttachments); | 5459 return std::min(m_maxDrawBuffers, m_maxColorAttachments); |
| 5517 } | 5460 } |
| 5518 | 5461 |
| 5519 GC3Dint WebGLRenderingContext::getMaxColorAttachments() | 5462 GC3Dint WebGLRenderingContextBase::getMaxColorAttachments() |
| 5520 { | 5463 { |
| 5521 if (isContextLost() || !m_webglDrawBuffers) | 5464 if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) |
| 5522 return 0; | 5465 return 0; |
| 5523 if (!m_maxColorAttachments) | 5466 if (!m_maxColorAttachments) |
| 5524 m_context->getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &m_maxCo lorAttachments); | 5467 m_context->getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &m_maxCo lorAttachments); |
| 5525 return m_maxColorAttachments; | 5468 return m_maxColorAttachments; |
| 5526 } | 5469 } |
| 5527 | 5470 |
| 5528 void WebGLRenderingContext::setBackDrawBuffer(GC3Denum buf) | 5471 void WebGLRenderingContextBase::setBackDrawBuffer(GC3Denum buf) |
| 5529 { | 5472 { |
| 5530 m_backDrawBuffer = buf; | 5473 m_backDrawBuffer = buf; |
| 5531 } | 5474 } |
| 5532 | 5475 |
| 5533 void WebGLRenderingContext::restoreCurrentFramebuffer() | 5476 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| 5534 { | 5477 { |
| 5535 bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_framebufferBinding.get()); | 5478 bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_framebufferBinding.get()); |
| 5536 } | 5479 } |
| 5537 | 5480 |
| 5538 void WebGLRenderingContext::restoreCurrentTexture2D() | 5481 void WebGLRenderingContextBase::restoreCurrentTexture2D() |
| 5539 { | 5482 { |
| 5540 bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUni t].m_texture2DBinding.get()); | 5483 bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUni t].m_texture2DBinding.get()); |
| 5541 } | 5484 } |
| 5542 | 5485 |
| 5543 void WebGLRenderingContext::multisamplingChanged(bool enabled) | 5486 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) |
| 5544 { | 5487 { |
| 5545 if (m_multisamplingAllowed != enabled) { | 5488 if (m_multisamplingAllowed != enabled) { |
| 5546 m_multisamplingAllowed = enabled; | 5489 m_multisamplingAllowed = enabled; |
| 5547 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ; | 5490 forceLostContext(WebGLRenderingContextBase::AutoRecoverSyntheticLostCont ext); |
| 5548 } | 5491 } |
| 5549 } | 5492 } |
| 5550 | 5493 |
| 5551 void WebGLRenderingContext::findNewMaxEnabledAttribIndex() | 5494 void WebGLRenderingContextBase::findNewMaxEnabledAttribIndex() |
| 5552 { | 5495 { |
| 5553 // Trace backwards from the current max to find the new max enabled attrib i ndex | 5496 // Trace backwards from the current max to find the new max enabled attrib i ndex |
| 5554 int startIndex = m_onePlusMaxEnabledAttribIndex - 1; | 5497 int startIndex = m_onePlusMaxEnabledAttribIndex - 1; |
| 5555 for (int i = startIndex; i >= 0; --i) { | 5498 for (int i = startIndex; i >= 0; --i) { |
| 5556 if (m_boundVertexArrayObject->getVertexAttribState(i).enabled) { | 5499 if (m_boundVertexArrayObject->getVertexAttribState(i).enabled) { |
| 5557 m_onePlusMaxEnabledAttribIndex = i + 1; | 5500 m_onePlusMaxEnabledAttribIndex = i + 1; |
| 5558 return; | 5501 return; |
| 5559 } | 5502 } |
| 5560 } | 5503 } |
| 5561 m_onePlusMaxEnabledAttribIndex = 0; | 5504 m_onePlusMaxEnabledAttribIndex = 0; |
| 5562 } | 5505 } |
| 5563 | 5506 |
| 5564 void WebGLRenderingContext::findNewMaxNonDefaultTextureUnit() | 5507 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() |
| 5565 { | 5508 { |
| 5566 // Trace backwards from the current max to find the new max non-default text ure unit | 5509 // Trace backwards from the current max to find the new max non-default text ure unit |
| 5567 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; | 5510 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; |
| 5568 for (int i = startIndex; i >= 0; --i) { | 5511 for (int i = startIndex; i >= 0; --i) { |
| 5569 if (m_textureUnits[i].m_texture2DBinding | 5512 if (m_textureUnits[i].m_texture2DBinding |
| 5570 || m_textureUnits[i].m_textureCubeMapBinding) { | 5513 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5571 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5514 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5572 return; | 5515 return; |
| 5573 } | 5516 } |
| 5574 } | 5517 } |
| 5575 m_onePlusMaxNonDefaultTextureUnit = 0; | 5518 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5576 } | 5519 } |
| 5577 | 5520 |
| 5578 } // namespace WebCore | 5521 } // namespace WebCore |
| OLD | NEW |