Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.cpp

Issue 17230006: Implement WEBGL_shared_resources Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | Source/core/html/canvas/WebGLShader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 #include "core/html/canvas/ANGLEInstancedArrays.h" 36 #include "core/html/canvas/ANGLEInstancedArrays.h"
37 #include "core/html/canvas/EXTFragDepth.h" 37 #include "core/html/canvas/EXTFragDepth.h"
38 #include "core/html/canvas/EXTTextureFilterAnisotropic.h" 38 #include "core/html/canvas/EXTTextureFilterAnisotropic.h"
39 #include "core/html/canvas/OESElementIndexUint.h" 39 #include "core/html/canvas/OESElementIndexUint.h"
40 #include "core/html/canvas/OESStandardDerivatives.h" 40 #include "core/html/canvas/OESStandardDerivatives.h"
41 #include "core/html/canvas/OESTextureFloat.h" 41 #include "core/html/canvas/OESTextureFloat.h"
42 #include "core/html/canvas/OESTextureFloatLinear.h" 42 #include "core/html/canvas/OESTextureFloatLinear.h"
43 #include "core/html/canvas/OESTextureHalfFloat.h" 43 #include "core/html/canvas/OESTextureHalfFloat.h"
44 #include "core/html/canvas/OESTextureHalfFloatLinear.h" 44 #include "core/html/canvas/OESTextureHalfFloatLinear.h"
45 #include "core/html/canvas/OESVertexArrayObject.h" 45 #include "core/html/canvas/OESVertexArrayObject.h"
46 #include "core/html/canvas/WebGLAcquireSharedResourceCallback.h"
46 #include "core/html/canvas/WebGLActiveInfo.h" 47 #include "core/html/canvas/WebGLActiveInfo.h"
47 #include "core/html/canvas/WebGLBuffer.h" 48 #include "core/html/canvas/WebGLBuffer.h"
48 #include "core/html/canvas/WebGLCompressedTextureATC.h" 49 #include "core/html/canvas/WebGLCompressedTextureATC.h"
49 #include "core/html/canvas/WebGLCompressedTexturePVRTC.h" 50 #include "core/html/canvas/WebGLCompressedTexturePVRTC.h"
50 #include "core/html/canvas/WebGLCompressedTextureS3TC.h" 51 #include "core/html/canvas/WebGLCompressedTextureS3TC.h"
51 #include "core/html/canvas/WebGLContextAttributes.h" 52 #include "core/html/canvas/WebGLContextAttributes.h"
52 #include "core/html/canvas/WebGLContextEvent.h" 53 #include "core/html/canvas/WebGLContextEvent.h"
53 #include "core/html/canvas/WebGLContextGroup.h" 54 #include "core/html/canvas/WebGLContextGroup.h"
54 #include "core/html/canvas/WebGLDebugRendererInfo.h" 55 #include "core/html/canvas/WebGLDebugRendererInfo.h"
55 #include "core/html/canvas/WebGLDebugShaders.h" 56 #include "core/html/canvas/WebGLDebugShaders.h"
56 #include "core/html/canvas/WebGLDepthTexture.h" 57 #include "core/html/canvas/WebGLDepthTexture.h"
57 #include "core/html/canvas/WebGLDrawBuffers.h" 58 #include "core/html/canvas/WebGLDrawBuffers.h"
58 #include "core/html/canvas/WebGLFramebuffer.h" 59 #include "core/html/canvas/WebGLFramebuffer.h"
59 #include "core/html/canvas/WebGLLoseContext.h" 60 #include "core/html/canvas/WebGLLoseContext.h"
60 #include "core/html/canvas/WebGLProgram.h" 61 #include "core/html/canvas/WebGLProgram.h"
61 #include "core/html/canvas/WebGLRenderbuffer.h" 62 #include "core/html/canvas/WebGLRenderbuffer.h"
62 #include "core/html/canvas/WebGLShader.h" 63 #include "core/html/canvas/WebGLShader.h"
63 #include "core/html/canvas/WebGLShaderPrecisionFormat.h" 64 #include "core/html/canvas/WebGLShaderPrecisionFormat.h"
65 #include "core/html/canvas/WebGLShareGroup.h"
66 #include "core/html/canvas/WebGLSharedResources.h"
64 #include "core/html/canvas/WebGLTexture.h" 67 #include "core/html/canvas/WebGLTexture.h"
65 #include "core/html/canvas/WebGLUniformLocation.h" 68 #include "core/html/canvas/WebGLUniformLocation.h"
66 #include "core/inspector/InspectorInstrumentation.h" 69 #include "core/inspector/InspectorInstrumentation.h"
67 #include "core/loader/FrameLoader.h" 70 #include "core/loader/FrameLoader.h"
68 #include "core/loader/FrameLoaderClient.h" 71 #include "core/loader/FrameLoaderClient.h"
69 #include "core/loader/cache/CachedImage.h" 72 #include "core/loader/cache/CachedImage.h"
70 #include "core/page/Frame.h" 73 #include "core/page/Frame.h"
71 #include "core/page/Page.h" 74 #include "core/page/Page.h"
72 #include "core/page/Settings.h" 75 #include "core/page/Settings.h"
73 #include "core/platform/NotImplemented.h" 76 #include "core/platform/NotImplemented.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 520
518 if (!context || !context->makeContextCurrent()) { 521 if (!context || !context->makeContextCurrent()) {
519 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Could not create a WebGL context.")); 522 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Could not create a WebGL context."));
520 return nullptr; 523 return nullptr;
521 } 524 }
522 525
523 Extensions3D* extensions = context->getExtensions(); 526 Extensions3D* extensions = context->getExtensions();
524 if (extensions->supports("GL_EXT_debug_marker")) 527 if (extensions->supports("GL_EXT_debug_marker"))
525 extensions->pushGroupMarkerEXT("WebGLRenderingContext"); 528 extensions->pushGroupMarkerEXT("WebGLRenderingContext");
526 529
527 OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRendering Context(canvas, context, attributes, requestedAttributes)); 530 RefPtr<WebGLContextGroup> contextGroup(attrs->group()
531 ? attrs->group()->contextGroup()
532 : WebGLContextGroup::create());
533
534 OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRendering Context(canvas, context, attributes, requestedAttributes, contextGroup));
528 renderingContext->suspendIfNeeded(); 535 renderingContext->suspendIfNeeded();
529 536
530 if (renderingContext->m_drawingBuffer->isZeroSized()) { 537 if (renderingContext->m_drawingBuffer->isZeroSized()) {
531 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Could not create a WebGL context.")); 538 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontex tcreationerrorEvent, false, true, "Could not create a WebGL context."));
532 return nullptr; 539 return nullptr;
533 } 540 }
534 541
535 return renderingContext.release(); 542 return renderingContext.release();
536 } 543 }
537 544
538 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa ssRefPtr<GraphicsContext3D> context, GraphicsContext3D::Attributes attributes, G raphicsContext3D::Attributes requestedAttributes) 545 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa ssRefPtr<GraphicsContext3D> context, GraphicsContext3D::Attributes attributes, G raphicsContext3D::Attributes requestedAttributes, PassRefPtr<WebGLContextGroup> contextGroup)
539 : CanvasRenderingContext(passedCanvas) 546 : CanvasRenderingContext(passedCanvas)
540 , ActiveDOMObject(passedCanvas->document()) 547 , ActiveDOMObject(passedCanvas->document())
541 , m_context(context) 548 , m_context(context)
549 , m_contextGroup(contextGroup)
542 , m_drawingBuffer(0) 550 , m_drawingBuffer(0)
543 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont extLostEvent) 551 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont extLostEvent)
544 , m_restoreAllowed(false) 552 , m_restoreAllowed(false)
545 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext) 553 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext)
546 , m_videoCache(4) 554 , m_videoCache(4)
547 , m_contextLost(false) 555 , m_contextLost(false)
548 , m_contextLostMode(SyntheticLostContext) 556 , m_contextLostMode(SyntheticLostContext)
549 , m_attributes(attributes) 557 , m_attributes(attributes)
550 , m_requestedAttributes(requestedAttributes) 558 , m_requestedAttributes(requestedAttributes)
551 , m_synthesizedErrorsToConsole(true) 559 , m_synthesizedErrorsToConsole(true)
552 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) 560 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
553 , m_multisamplingAllowed(false) 561 , m_multisamplingAllowed(false)
554 , m_multisamplingObserverRegistered(false) 562 , m_multisamplingObserverRegistered(false)
555 { 563 {
556 ASSERT(m_context); 564 ASSERT(m_context);
557 ScriptWrappable::init(this); 565 ScriptWrappable::init(this);
558 566
559 m_contextGroup = WebGLContextGroup::create();
560 m_contextGroup->addContext(this); 567 m_contextGroup->addContext(this);
561 568
562 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; 569 m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
563 m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDi ms); 570 m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDi ms);
564 571
565 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); 572 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager());
566 573
567 // Create the DrawingBuffer and initialize the platform layer. 574 // Create the DrawingBuffer and initialize the platform layer.
568 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; 575 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
569 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release()); 576 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release());
(...skipping 20 matching lines...) Expand all
590 registerExtension<WebGLCompressedTextureATC>(m_webglCompressedTextureATC, fa lse, false, true, webkitPrefix); 597 registerExtension<WebGLCompressedTextureATC>(m_webglCompressedTextureATC, fa lse, false, true, webkitPrefix);
591 registerExtension<WebGLCompressedTexturePVRTC>(m_webglCompressedTexturePVRTC , false, false, true, webkitPrefix); 598 registerExtension<WebGLCompressedTexturePVRTC>(m_webglCompressedTexturePVRTC , false, false, true, webkitPrefix);
592 registerExtension<WebGLCompressedTextureS3TC>(m_webglCompressedTextureS3TC, false, false, true, bothPrefixes); 599 registerExtension<WebGLCompressedTextureS3TC>(m_webglCompressedTextureS3TC, false, false, true, bothPrefixes);
593 registerExtension<WebGLDepthTexture>(m_webglDepthTexture, false, false, true , bothPrefixes); 600 registerExtension<WebGLDepthTexture>(m_webglDepthTexture, false, false, true , bothPrefixes);
594 registerExtension<WebGLLoseContext>(m_webglLoseContext, false, false, false, bothPrefixes); 601 registerExtension<WebGLLoseContext>(m_webglLoseContext, false, false, false, bothPrefixes);
595 602
596 // Register draft extensions. 603 // Register draft extensions.
597 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays, false, true, false, unprefixed); 604 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays, false, true, false, unprefixed);
598 registerExtension<EXTFragDepth>(m_extFragDepth, false, true, false, unprefix ed); 605 registerExtension<EXTFragDepth>(m_extFragDepth, false, true, false, unprefix ed);
599 registerExtension<WebGLDrawBuffers>(m_webglDrawBuffers, false, true, false, unprefixed); 606 registerExtension<WebGLDrawBuffers>(m_webglDrawBuffers, false, true, false, unprefixed);
607 registerExtension<WebGLSharedResources>(m_webglSharedResources, false, true, false, unprefixed);
600 608
601 // Register privileged extensions. 609 // Register privileged extensions.
602 registerExtension<WebGLDebugRendererInfo>(m_webglDebugRendererInfo, true, fa lse, false, unprefixed); 610 registerExtension<WebGLDebugRendererInfo>(m_webglDebugRendererInfo, true, fa lse, false, unprefixed);
603 registerExtension<WebGLDebugShaders>(m_webglDebugShaders, true, false, false , unprefixed); 611 registerExtension<WebGLDebugShaders>(m_webglDebugShaders, true, false, false , unprefixed);
604 } 612 }
605 613
606 void WebGLRenderingContext::initializeNewContext() 614 void WebGLRenderingContext::initializeNewContext()
607 { 615 {
608 ASSERT(!isContextLost()); 616 ASSERT(!isContextLost());
609 m_needsUpdate = true; 617 m_needsUpdate = true;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; 1006 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0;
999 m_context->activeTexture(texture); 1007 m_context->activeTexture(texture);
1000 1008
1001 m_drawingBuffer->setActiveTextureUnit(texture); 1009 m_drawingBuffer->setActiveTextureUnit(texture);
1002 1010
1003 } 1011 }
1004 1012
1005 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha der, ExceptionCode& ec) 1013 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha der, ExceptionCode& ec)
1006 { 1014 {
1007 UNUSED_PARAM(ec); 1015 UNUSED_PARAM(ec);
1008 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) 1016 bool boundSinceLastAcquire;
1017 bool deleted;
1018 if (isContextLost()
1019 || !validateWebGLSharedObject("attachShader", program, WebGLSharedObject ::Exclusive)
1020 || !checkSharedObjectToBeBound("attachShader", shader, deleted, boundSin ceLastAcquire)) {
1009 return; 1021 return;
1022 }
1023 if (deleted) {
1024 shader = 0;
1025 }
1010 if (!program->attachShader(shader)) { 1026 if (!program->attachShader(shader)) {
1011 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader"); 1027 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader");
1012 return; 1028 return;
1013 } 1029 }
1014 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); 1030 m_context->attachShader(objectOrZero(program), objectOrZero(shader));
1015 shader->onAttached(); 1031 if (shader) {
1032 shader->onAttached();
1033 if (!boundSinceLastAcquire) {
1034 shader->markAsBoundSinceLastAcquireForContext(this);
1035 }
1036 }
1016 } 1037 }
1017 1038
1018 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i ndex, const String& name, ExceptionCode& ec) 1039 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i ndex, const String& name, ExceptionCode& ec)
1019 { 1040 {
1020 UNUSED_PARAM(ec); 1041 UNUSED_PARAM(ec);
1021 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) 1042 if (isContextLost() || !validateWebGLSharedObject("bindAttribLocation", prog ram, WebGLSharedObject::Exclusive))
1022 return; 1043 return;
1023 if (!validateLocationLength("bindAttribLocation", name)) 1044 if (!validateLocationLength("bindAttribLocation", name))
1024 return; 1045 return;
1025 if (!validateString("bindAttribLocation", name)) 1046 if (!validateString("bindAttribLocation", name))
1026 return; 1047 return;
1027 if (isPrefixReserved(name)) { 1048 if (isPrefixReserved(name)) {
1028 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat ion", "reserved prefix"); 1049 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat ion", "reserved prefix");
1029 return; 1050 return;
1030 } 1051 }
1031 if (index >= m_maxVertexAttribs) { 1052 if (index >= m_maxVertexAttribs) {
1032 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation" , "index out of range"); 1053 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation" , "index out of range");
1033 return; 1054 return;
1034 } 1055 }
1035 m_context->bindAttribLocation(objectOrZero(program), index, name); 1056 m_context->bindAttribLocation(objectOrZero(program), index, name);
1036 } 1057 }
1037 1058
1038 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL Object* object, bool& deleted) 1059 bool WebGLRenderingContext::checkContextObjectToBeBound(const char* functionName , WebGLContextObject* object, bool& deleted)
1039 { 1060 {
1040 deleted = false; 1061 deleted = false;
1041 if (isContextLost()) 1062 if (isContextLost())
1042 return false; 1063 return false;
1043 if (object) { 1064 if (object) {
1044 if (!object->validate(contextGroup(), this)) { 1065 if (!object->validate(contextGroup(), this)) {
1045 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "object not from this context"); 1066 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "object not from this share group");
1046 return false; 1067 return false;
1047 } 1068 }
1048 deleted = !object->object(); 1069 deleted = !object->object();
1070 }
1071 return true;
1072 }
1073
1074 bool WebGLRenderingContext::checkSharedObjectToBeBound(const char* functionName, WebGLSharedObject* object, bool& deleted, bool& boundSinceLastAcquire)
1075 {
1076 deleted = false;
1077 if (isContextLost())
1078 return false;
1079 if (object) {
1080 if (!object->validate(functionName, this, WebGLSharedObject::ReadOnly, f alse, &boundSinceLastAcquire)) {
1081 return false;
1082 }
1083 deleted = !object->object();
1049 } 1084 }
1050 return true; 1085 return true;
1051 } 1086 }
1052 1087
1053 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer, Exc eptionCode& ec) 1088 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer, Exc eptionCode& ec)
1054 { 1089 {
1055 UNUSED_PARAM(ec); 1090 UNUSED_PARAM(ec);
1056 bool deleted; 1091 bool deleted;
1057 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) 1092 bool boundSinceLastAcquire;
1093 if (!checkSharedObjectToBeBound("bindBuffer", buffer, deleted, boundSinceLas tAcquire))
1058 return; 1094 return;
1059 if (deleted) 1095 if (deleted)
1060 buffer = 0; 1096 buffer = 0;
1061 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { 1097 if (buffer && buffer->getTarget() && buffer->getTarget() != target) {
1062 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b uffers can not be used with multiple targets"); 1098 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b uffers can not be used with multiple targets");
1063 return; 1099 return;
1064 } 1100 }
1065 if (target == GraphicsContext3D::ARRAY_BUFFER) 1101 if (target == GraphicsContext3D::ARRAY_BUFFER)
1066 m_boundArrayBuffer = buffer; 1102 m_boundArrayBuffer = buffer;
1067 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) 1103 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER)
1068 m_boundVertexArrayObject->setElementArrayBuffer(buffer); 1104 m_boundVertexArrayObject->setElementArrayBuffer(buffer);
1069 else { 1105 else {
1070 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali d target"); 1106 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali d target");
1071 return; 1107 return;
1072 } 1108 }
1073 1109
1074 m_context->bindBuffer(target, objectOrZero(buffer)); 1110 m_context->bindBuffer(target, objectOrZero(buffer));
1075 if (buffer) 1111 if (buffer) {
1076 buffer->setTarget(target); 1112 buffer->setTarget(target);
1113 if (!boundSinceLastAcquire) {
1114 buffer->markAsBoundSinceLastAcquireForContext(this);
1115 }
1116 }
1077 } 1117 }
1078 1118
1079 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b uffer, ExceptionCode& ec) 1119 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b uffer, ExceptionCode& ec)
1080 { 1120 {
1081 UNUSED_PARAM(ec); 1121 UNUSED_PARAM(ec);
1082 bool deleted; 1122 bool deleted;
1083 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) 1123 if (!checkContextObjectToBeBound("bindFramebuffer", buffer, deleted))
1084 return; 1124 return;
1085 if (deleted) 1125 if (deleted)
1086 buffer = 0; 1126 buffer = 0;
1087 if (target != GraphicsContext3D::FRAMEBUFFER) { 1127 if (target != GraphicsContext3D::FRAMEBUFFER) {
1088 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i nvalid target"); 1128 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i nvalid target");
1089 return; 1129 return;
1090 } 1130 }
1091 m_framebufferBinding = buffer; 1131 m_framebufferBinding = buffer;
1092 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ())); 1132 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ()));
1093 if (!m_framebufferBinding) { 1133 if (!m_framebufferBinding) {
1094 // Instead of binding fb 0, bind the drawing buffer. 1134 // Instead of binding fb 0, bind the drawing buffer.
1095 m_drawingBuffer->bind(); 1135 m_drawingBuffer->bind();
1096 } else 1136 } else
1097 m_context->bindFramebuffer(target, objectOrZero(buffer)); 1137 m_context->bindFramebuffer(target, objectOrZero(buffer));
1098 if (buffer) 1138 if (buffer)
1099 buffer->setHasEverBeenBound(); 1139 buffer->setHasEverBeenBound();
1100 applyStencilTest(); 1140 applyStencilTest();
1101 } 1141 }
1102 1142
1103 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer* renderBuffer, ExceptionCode& ec) 1143 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer* renderBuffer, ExceptionCode& ec)
1104 { 1144 {
1105 UNUSED_PARAM(ec); 1145 UNUSED_PARAM(ec);
1106 bool deleted; 1146 bool deleted;
1107 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) 1147 bool boundSinceLastAcquire;
1148 if (!checkSharedObjectToBeBound("bindRenderbuffer", renderBuffer, deleted, b oundSinceLastAcquire))
1108 return; 1149 return;
1109 if (deleted) 1150 if (deleted)
1110 renderBuffer = 0; 1151 renderBuffer = 0;
1111 if (target != GraphicsContext3D::RENDERBUFFER) { 1152 if (target != GraphicsContext3D::RENDERBUFFER) {
1112 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", " invalid target"); 1153 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", " invalid target");
1113 return; 1154 return;
1114 } 1155 }
1115 m_renderbufferBinding = renderBuffer; 1156 m_renderbufferBinding = renderBuffer;
1116 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); 1157 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer));
1117 if (renderBuffer) 1158 if (renderBuffer) {
1118 renderBuffer->setHasEverBeenBound(); 1159 renderBuffer->setHasEverBeenBound();
1160 if (!boundSinceLastAcquire) {
1161 renderBuffer->markAsBoundSinceLastAcquireForContext(this);
1162 }
1163 }
1119 } 1164 }
1120 1165
1121 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture, ExceptionCode& ec) 1166 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture, ExceptionCode& ec)
1122 { 1167 {
1123 UNUSED_PARAM(ec); 1168 UNUSED_PARAM(ec);
1124 bool deleted; 1169 bool deleted;
1125 if (!checkObjectToBeBound("bindTexture", texture, deleted)) 1170 bool boundSinceLastAcquire;
1171 if (!checkSharedObjectToBeBound("bindTexture", texture, deleted, boundSinceL astAcquire))
1126 return; 1172 return;
1127 if (deleted) 1173 if (deleted)
1128 texture = 0; 1174 texture = 0;
1129 if (texture && texture->getTarget() && texture->getTarget() != target) { 1175 if (texture && texture->getTarget() && texture->getTarget() != target) {
1130 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", " textures can not be used with multiple targets"); 1176 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", " textures can not be used with multiple targets");
1131 return; 1177 return;
1132 } 1178 }
1133 GC3Dint maxLevel = 0; 1179 GC3Dint maxLevel = 0;
1134 if (target == GraphicsContext3D::TEXTURE_2D) { 1180 if (target == GraphicsContext3D::TEXTURE_2D) {
1135 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; 1181 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture;
1136 maxLevel = m_maxTextureLevel; 1182 maxLevel = m_maxTextureLevel;
1137 1183
1138 if (!m_activeTextureUnit) 1184 if (!m_activeTextureUnit)
1139 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); 1185 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture));
1140 1186
1141 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { 1187 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) {
1142 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; 1188 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture;
1143 maxLevel = m_maxCubeMapTextureLevel; 1189 maxLevel = m_maxCubeMapTextureLevel;
1144 } else { 1190 } else {
1145 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "inval id target"); 1191 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "inval id target");
1146 return; 1192 return;
1147 } 1193 }
1148 m_context->bindTexture(target, objectOrZero(texture)); 1194 m_context->bindTexture(target, objectOrZero(texture));
1149 if (texture) 1195 if (texture) {
1150 texture->setTarget(target, maxLevel); 1196 texture->setTarget(target, maxLevel);
1197 if (!boundSinceLastAcquire) {
1198 texture->markAsBoundSinceLastAcquireForContext(this);
1199 }
1200 }
1151 1201
1152 // Note: previously we used to automatically set the TEXTURE_WRAP_R 1202 // Note: previously we used to automatically set the TEXTURE_WRAP_R
1153 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL 1203 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL
1154 // ES 2.0 doesn't expose this flag (a bug in the specification) and 1204 // ES 2.0 doesn't expose this flag (a bug in the specification) and
1155 // otherwise the application has no control over the seams in this 1205 // otherwise the application has no control over the seams in this
1156 // dimension. However, it appears that supporting this properly on all 1206 // dimension. However, it appears that supporting this properly on all
1157 // platforms is fairly involved (will require a HashMap from texture ID 1207 // platforms is fairly involved (will require a HashMap from texture ID
1158 // in all ports), and we have not had any complaints, so the logic has 1208 // in all ports), and we have not had any complaints, so the logic has
1159 // been removed. 1209 // been removed.
1160 1210
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 if (!data) 1331 if (!data)
1282 return; 1332 return;
1283 1333
1284 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->baseAddress()); 1334 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->baseAddress());
1285 } 1335 }
1286 1336
1287 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) 1337 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target)
1288 { 1338 {
1289 if (isContextLost()) 1339 if (isContextLost())
1290 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; 1340 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
1291 if (target != GraphicsContext3D::FRAMEBUFFER) { 1341 switch (target) {
1342 case GraphicsContext3D::FRAMEBUFFER:
1343 case Extensions3D::READ_FRAMEBUFFER:
1344 case Extensions3D::DRAW_FRAMEBUFFER:
1345 break;
1346 default:
1292 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat us", "invalid target"); 1347 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat us", "invalid target");
1293 return 0; 1348 return 0;
1294 } 1349 }
1295 if (!m_framebufferBinding || !m_framebufferBinding->object()) 1350 if (!m_framebufferBinding || !m_framebufferBinding->object())
1296 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; 1351 return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
1297 const char* reason = "framebuffer incomplete"; 1352 const char* reason = "framebuffer incomplete";
1298 GC3Denum result = m_framebufferBinding->checkStatus(&reason); 1353 WebGLSharedObject::AcquireMode neededAccessMode = (target == Extensions3D::R EAD_FRAMEBUFFER) ? WebGLSharedObject::ReadOnly : WebGLSharedObject::Exclusive;
1354 GC3Denum result = m_framebufferBinding->checkStatus(this, neededAccessMode, &reason);
1299 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { 1355 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
1300 printGLWarningToConsole("checkFramebufferStatus", reason); 1356 printGLWarningToConsole("checkFramebufferStatus", reason);
1301 return result; 1357 return result;
1302 } 1358 }
1303 result = m_context->checkFramebufferStatus(target); 1359 result = m_context->checkFramebufferStatus(target);
1304 return result; 1360 return result;
1305 } 1361 }
1306 1362
1307 void WebGLRenderingContext::clear(GC3Dbitfield mask) 1363 void WebGLRenderingContext::clear(GC3Dbitfield mask)
1308 { 1364 {
1309 if (isContextLost()) 1365 if (isContextLost())
1310 return; 1366 return;
1311 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_ BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { 1367 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_ BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
1312 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma sk"); 1368 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma sk");
1313 return; 1369 return;
1314 } 1370 }
1315 const char* reason = "framebuffer incomplete"; 1371 const char* reason = "framebuffer incomplete";
1316 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 1372 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare dObject::Exclusive, &reason)) {
1317 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle ar", reason); 1373 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle ar", reason);
1318 return; 1374 return;
1319 } 1375 }
1320 if (!clearIfComposited(mask)) 1376 if (!clearIfComposited(mask))
1321 m_context->clear(mask); 1377 m_context->clear(mask);
1322 markContextChanged(); 1378 markContextChanged();
1323 } 1379 }
1324 1380
1325 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC 3Dfloat a) 1381 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC 3Dfloat a)
1326 { 1382 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 m_colorMask[0] = red; 1420 m_colorMask[0] = red;
1365 m_colorMask[1] = green; 1421 m_colorMask[1] = green;
1366 m_colorMask[2] = blue; 1422 m_colorMask[2] = blue;
1367 m_colorMask[3] = alpha; 1423 m_colorMask[3] = alpha;
1368 m_context->colorMask(red, green, blue, alpha); 1424 m_context->colorMask(red, green, blue, alpha);
1369 } 1425 }
1370 1426
1371 void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec ) 1427 void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec )
1372 { 1428 {
1373 UNUSED_PARAM(ec); 1429 UNUSED_PARAM(ec);
1374 if (isContextLost() || !validateWebGLObject("compileShader", shader)) 1430 if (isContextLost() || !validateWebGLSharedObject("compileShader", shader, W ebGLSharedObject::Exclusive))
1375 return; 1431 return;
1376 m_context->compileShader(objectOrZero(shader)); 1432 m_context->compileShader(objectOrZero(shader));
1377 } 1433 }
1378 1434
1379 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, 1435 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
1380 GC3Dsizei height, GC3Dint borde r, ArrayBufferView* data) 1436 GC3Dsizei height, GC3Dint borde r, ArrayBufferView* data)
1381 { 1437 {
1382 if (isContextLost()) 1438 if (isContextLost())
1383 return; 1439 return;
1384 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) 1440 if (!validateTexFuncLevel("compressedTexImage2D", target, level))
1385 return; 1441 return;
1386 1442
1387 if (!validateCompressedTexFormat(internalformat)) { 1443 if (!validateCompressedTexFormat(internalformat)) {
1388 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D ", "invalid internalformat"); 1444 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D ", "invalid internalformat");
1389 return; 1445 return;
1390 } 1446 }
1391 if (border) { 1447 if (border) {
1392 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2 D", "border not 0"); 1448 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2 D", "border not 0");
1393 return; 1449 return;
1394 } 1450 }
1395 if (!validateCompressedTexDimensions("compressedTexImage2D", level, width, h eight, internalformat)) 1451 if (!validateCompressedTexDimensions("compressedTexImage2D", level, width, h eight, internalformat))
1396 return; 1452 return;
1397 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in ternalformat, data)) 1453 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in ternalformat, data))
1398 return; 1454 return;
1399 1455
1400 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t rue); 1456 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t rue, WebGLSharedObject::Exclusive);
1401 if (!tex) 1457 if (!tex)
1402 return; 1458 return;
1403 if (!isGLES2NPOTStrict()) { 1459 if (!isGLES2NPOTStrict()) {
1404 if (level && WebGLTexture::isNPOT(width, height)) { 1460 if (level && WebGLTexture::isNPOT(width, height)) {
1405 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm age2D", "level > 0 not power of 2"); 1461 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm age2D", "level > 0 not power of 2");
1406 return; 1462 return;
1407 } 1463 }
1408 } 1464 }
1409 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid th, height, 1465 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid th, height,
1410 border, data->byteLength(), data-> baseAddress()); 1466 border, data->byteLength(), data-> baseAddress());
1411 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); 1467 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE);
1412 } 1468 }
1413 1469
1414 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev el, GC3Dint xoffset, GC3Dint yoffset, 1470 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev el, GC3Dint xoffset, GC3Dint yoffset,
1415 GC3Dsizei width, GC3Dsizei h eight, GC3Denum format, ArrayBufferView* data) 1471 GC3Dsizei width, GC3Dsizei h eight, GC3Denum format, ArrayBufferView* data)
1416 { 1472 {
1417 if (isContextLost()) 1473 if (isContextLost())
1418 return; 1474 return;
1419 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) 1475 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level))
1420 return; 1476 return;
1421 if (!validateCompressedTexFormat(format)) { 1477 if (!validateCompressedTexFormat(format)) {
1422 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag e2D", "invalid format"); 1478 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag e2D", "invalid format");
1423 return; 1479 return;
1424 } 1480 }
1425 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data)) 1481 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data))
1426 return; 1482 return;
1427 1483
1428 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target , true); 1484 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target , true, WebGLSharedObject::Exclusive);
1429 if (!tex) 1485 if (!tex)
1430 return; 1486 return;
1431 1487
1432 if (format != tex->getInternalFormat(target, level)) { 1488 if (format != tex->getInternalFormat(target, level)) {
1433 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu bImage2D", "format does not match texture format"); 1489 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu bImage2D", "format does not match texture format");
1434 return; 1490 return;
1435 } 1491 }
1436 1492
1437 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l evel, xoffset, yoffset, width, height, format, tex)) 1493 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l evel, xoffset, yoffset, width, height, format, tex))
1438 return; 1494 return;
(...skipping 12 matching lines...) Expand all
1451 } 1507 }
1452 1508
1453 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3 Dint border) 1509 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3 Dint border)
1454 { 1510 {
1455 if (isContextLost()) 1511 if (isContextLost())
1456 return; 1512 return;
1457 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l evel, internalformat, width, height, border, internalformat, GraphicsContext3D:: UNSIGNED_BYTE)) 1513 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l evel, internalformat, width, height, border, internalformat, GraphicsContext3D:: UNSIGNED_BYTE))
1458 return; 1514 return;
1459 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) 1515 if (!validateSettableTexFormat("copyTexImage2D", internalformat))
1460 return; 1516 return;
1461 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); 1517 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true, W ebGLSharedObject::Exclusive);
1462 if (!tex) 1518 if (!tex)
1463 return; 1519 return;
1464 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound FramebufferColorFormat())) { 1520 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound FramebufferColorFormat())) {
1465 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D" , "framebuffer is incompatible format"); 1521 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D" , "framebuffer is incompatible format");
1466 return; 1522 return;
1467 } 1523 }
1468 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { 1524 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) {
1469 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "l evel > 0 not power of 2"); 1525 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "l evel > 0 not power of 2");
1470 return; 1526 return;
1471 } 1527 }
1472 const char* reason = "framebuffer incomplete"; 1528 const char* reason = "framebuffer incomplete";
1473 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 1529 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare dObject::ReadOnly, &reason)) {
1474 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexImage2D", reason); 1530 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexImage2D", reason);
1475 return; 1531 return;
1476 } 1532 }
1477 clearIfComposited(); 1533 clearIfComposited();
1478 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); 1534 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get());
1479 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height , border); 1535 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height , border);
1480 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. 1536 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted.
1481 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); 1537 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE);
1482 } 1538 }
1483 1539
1484 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) 1540 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
1485 { 1541 {
1486 if (isContextLost()) 1542 if (isContextLost())
1487 return; 1543 return;
1488 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) 1544 if (!validateTexFuncLevel("copyTexSubImage2D", target, level))
1489 return; 1545 return;
1490 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true ); 1546 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true , WebGLSharedObject::Exclusive);
1491 if (!tex) 1547 if (!tex)
1492 return; 1548 return;
1493 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c opyTexSubImage2D", width, height)) 1549 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c opyTexSubImage2D", width, height))
1494 return; 1550 return;
1495 // Before checking if it is in the range, check if overflow happens first. 1551 // Before checking if it is in the range, check if overflow happens first.
1496 if (xoffset + width < 0 || yoffset + height < 0) { 1552 if (xoffset + width < 0 || yoffset + height < 0) {
1497 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "bad dimensions"); 1553 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "bad dimensions");
1498 return; 1554 return;
1499 } 1555 }
1500 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex ->getHeight(target, level)) { 1556 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex ->getHeight(target, level)) {
1501 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "rectangle out of range"); 1557 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "rectangle out of range");
1502 return; 1558 return;
1503 } 1559 }
1504 GC3Denum internalformat = tex->getInternalFormat(target, level); 1560 GC3Denum internalformat = tex->getInternalFormat(target, level);
1505 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) 1561 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat))
1506 return; 1562 return;
1507 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound FramebufferColorFormat())) { 1563 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound FramebufferColorFormat())) {
1508 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage 2D", "framebuffer is incompatible format"); 1564 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage 2D", "framebuffer is incompatible format");
1509 return; 1565 return;
1510 } 1566 }
1511 const char* reason = "framebuffer incomplete"; 1567 const char* reason = "framebuffer incomplete";
1512 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 1568 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare dObject::ReadOnly, &reason)) {
1513 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexSubImage2D", reason); 1569 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexSubImage2D", reason);
1514 return; 1570 return;
1515 } 1571 }
1516 clearIfComposited(); 1572 clearIfComposited();
1517 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); 1573 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get());
1518 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h eight); 1574 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h eight);
1519 } 1575 }
1520 1576
1521 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() 1577 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer()
1522 { 1578 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 return o; 1646 return o;
1591 } 1647 }
1592 1648
1593 void WebGLRenderingContext::cullFace(GC3Denum mode) 1649 void WebGLRenderingContext::cullFace(GC3Denum mode)
1594 { 1650 {
1595 if (isContextLost()) 1651 if (isContextLost())
1596 return; 1652 return;
1597 m_context->cullFace(mode); 1653 m_context->cullFace(mode);
1598 } 1654 }
1599 1655
1600 bool WebGLRenderingContext::deleteObject(WebGLObject* object) 1656 bool WebGLRenderingContext::deleteContextObject(const char* functionName, WebGLC ontextObject* object)
1601 { 1657 {
1602 if (isContextLost() || !object) 1658 if (isContextLost() || !object)
1603 return false; 1659 return false;
1604 if (!object->validate(contextGroup(), this)) { 1660 if (!object->validate(contextGroup(), this)) {
1605 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "objec t does not belong to this context"); 1661 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o bject does not belong to this share group");
1662 return false;
1663 }
1664 if (object->object()) {
1665 // We need to pass in context here because we want
1666 // things in this context unbound.
1667 object->deleteObject(graphicsContext3D());
1668 }
1669 return true;
1670 }
1671
1672 bool WebGLRenderingContext::deleteSharedObject(const char* functionName, WebGLSh aredObject* object)
1673 {
1674 if (isContextLost() || !object)
1675 return false;
1676 if (!object->validate(functionName, this, WebGLSharedObject::Exclusive, true , 0)) {
1606 return false; 1677 return false;
1607 } 1678 }
1608 if (object->object()) 1679 if (object->object())
1609 // We need to pass in context here because we want 1680 // We need to pass in context here because we want
1610 // things in this context unbound. 1681 // things in this context unbound.
1611 object->deleteObject(graphicsContext3D()); 1682 object->deleteObject(graphicsContext3D());
1612 return true; 1683 return true;
1613 } 1684 }
1614 1685
1615 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) 1686 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer)
1616 { 1687 {
1617 if (!deleteObject(buffer)) 1688 if (!deleteSharedObject("deleteBuffer", buffer))
1618 return; 1689 return;
1619 if (m_boundArrayBuffer == buffer) 1690 if (m_boundArrayBuffer == buffer)
1620 m_boundArrayBuffer = 0; 1691 m_boundArrayBuffer = 0;
1621 1692
1622 m_boundVertexArrayObject->unbindBuffer(buffer); 1693 m_boundVertexArrayObject->unbindBuffer(buffer);
1623 } 1694 }
1624 1695
1625 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) 1696 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer)
1626 { 1697 {
1627 if (!deleteObject(framebuffer)) 1698 if (!deleteContextObject("deleteFramebuffer", framebuffer))
1628 return; 1699 return;
1629 if (framebuffer == m_framebufferBinding) { 1700 if (framebuffer == m_framebufferBinding) {
1630 m_framebufferBinding = 0; 1701 m_framebufferBinding = 0;
1631 m_drawingBuffer->setFramebufferBinding(0); 1702 m_drawingBuffer->setFramebufferBinding(0);
1632 // Have to call bindFramebuffer here to bind back to internal fbo. 1703 // Have to call bindFramebuffer here to bind back to internal fbo.
1633 m_drawingBuffer->bind(); 1704 m_drawingBuffer->bind();
1634 } 1705 }
1635 } 1706 }
1636 1707
1637 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) 1708 void WebGLRenderingContext::deleteProgram(WebGLProgram* program)
1638 { 1709 {
1639 deleteObject(program); 1710 deleteSharedObject("deleteProgram", program);
1640 // We don't reset m_currentProgram to 0 here because the deletion of the 1711 // We don't reset m_currentProgram to 0 here because the deletion of the
1641 // current program is delayed. 1712 // current program is delayed.
1642 } 1713 }
1643 1714
1644 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) 1715 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer)
1645 { 1716 {
1646 if (!deleteObject(renderbuffer)) 1717 if (!deleteSharedObject("deleteRenderbuffer", renderbuffer))
1647 return; 1718 return;
1648 if (renderbuffer == m_renderbufferBinding) 1719 if (renderbuffer == m_renderbufferBinding)
1649 m_renderbufferBinding = 0; 1720 m_renderbufferBinding = 0;
1650 if (m_framebufferBinding) 1721 if (m_framebufferBinding)
1651 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer) ; 1722 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer) ;
1652 } 1723 }
1653 1724
1654 void WebGLRenderingContext::deleteShader(WebGLShader* shader) 1725 void WebGLRenderingContext::deleteShader(WebGLShader* shader)
1655 { 1726 {
1656 deleteObject(shader); 1727 deleteSharedObject("deleteShader", shader);
1657 } 1728 }
1658 1729
1659 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) 1730 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture)
1660 { 1731 {
1661 if (!deleteObject(texture)) 1732 if (!deleteSharedObject("deleteTexture", texture))
1662 return; 1733 return;
1663 for (size_t i = 0; i < m_textureUnits.size(); ++i) { 1734 for (size_t i = 0; i < m_textureUnits.size(); ++i) {
1664 if (texture == m_textureUnits[i].m_texture2DBinding) 1735 if (texture == m_textureUnits[i].m_texture2DBinding)
1665 m_textureUnits[i].m_texture2DBinding = 0; 1736 m_textureUnits[i].m_texture2DBinding = 0;
1666 if (texture == m_textureUnits[i].m_textureCubeMapBinding) 1737 if (texture == m_textureUnits[i].m_textureCubeMapBinding)
1667 m_textureUnits[i].m_textureCubeMapBinding = 0; 1738 m_textureUnits[i].m_textureCubeMapBinding = 0;
1668 } 1739 }
1669 if (m_framebufferBinding) 1740 if (m_framebufferBinding)
1670 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); 1741 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture);
1671 } 1742 }
(...skipping 20 matching lines...) Expand all
1692 if (zNear > zFar) { 1763 if (zNear > zFar) {
1693 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z Near > zFar"); 1764 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z Near > zFar");
1694 return; 1765 return;
1695 } 1766 }
1696 m_context->depthRange(zNear, zFar); 1767 m_context->depthRange(zNear, zFar);
1697 } 1768 }
1698 1769
1699 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha der, ExceptionCode& ec) 1770 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha der, ExceptionCode& ec)
1700 { 1771 {
1701 UNUSED_PARAM(ec); 1772 UNUSED_PARAM(ec);
1702 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) 1773 bool boundSinceLastAcquire;
1774 bool deleted;
1775 // NOTE: We explicitly don't check the shader has been bound since the only way to mark a shader as bound is to attach it which means
1776 // there would be no way to detach a shader in context other than the one
1777 // that attached it.
1778 if (isContextLost()
1779 || !validateWebGLSharedObject("detachShader", program, WebGLSharedObject ::Exclusive)
1780 || !checkSharedObjectToBeBound("detachShader", shader, deleted, boundSin ceLastAcquire)) {
1703 return; 1781 return;
1782 }
1783 if (deleted) {
1784 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader deleted");
1785 return;
1786 }
1704 if (!program->detachShader(shader)) { 1787 if (!program->detachShader(shader)) {
1705 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached"); 1788 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached");
1706 return; 1789 return;
1707 } 1790 }
1708 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); 1791 m_context->detachShader(objectOrZero(program), objectOrZero(shader));
1709 shader->onDetached(graphicsContext3D()); 1792 shader->onDetached(graphicsContext3D());
1710 } 1793 }
1711 1794
1712 void WebGLRenderingContext::disable(GC3Denum cap) 1795 void WebGLRenderingContext::disable(GC3Denum cap)
1713 { 1796 {
(...skipping 19 matching lines...) Expand all
1733 if (index >= m_maxVertexAttribs) { 1816 if (index >= m_maxVertexAttribs) {
1734 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttrib Array", "index out of range"); 1817 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttrib Array", "index out of range");
1735 return; 1818 return;
1736 } 1819 }
1737 1820
1738 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); 1821 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index);
1739 state.enabled = false; 1822 state.enabled = false;
1740 m_context->disableVertexAttribArray(index); 1823 m_context->disableVertexAttribArray(index);
1741 } 1824 }
1742 1825
1743 bool WebGLRenderingContext::validateRenderingState() 1826 bool WebGLRenderingContext::validateRenderingState(const char* functionName)
1744 { 1827 {
1745 if (!m_currentProgram) 1828 if (!m_currentProgram)
1746 return false; 1829 return false;
1747 1830
1831 if (!isAcquiredForReading(functionName, m_currentProgram.get())) {
1832 return false;
1833 }
1834
1748 // Look in each enabled vertex attrib and check if they've been bound to a b uffer. 1835 // Look in each enabled vertex attrib and check if they've been bound to a b uffer.
1749 for (unsigned i = 0; i < m_maxVertexAttribs; ++i) { 1836 for (unsigned i = 0; i < m_maxVertexAttribs; ++i) {
1750 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i); 1837 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArray Object->getVertexAttribState(i);
1751 if (state.enabled 1838 if (state.enabled) {
1752 && (!state.bufferBinding || !state.bufferBinding->object())) 1839 if (!state.bufferBinding || !state.bufferBinding->object()) {
1753 return false; 1840 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, function Name, "attribs enabled with no buffer bound");
1841 return false;
1842 }
1843 if (!isAcquiredForReading(functionName, state.bufferBinding.get())) {
1844 return false;
1845 }
1846 }
1754 } 1847 }
1755 1848
1756 return true; 1849 return true;
1757 } 1850 }
1758 1851
1759 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO bject* object) 1852 bool WebGLRenderingContext::isAcquiredForModification(const char* functionName, WebGLSharedObject* object)
1853 {
1854 return validateWebGLSharedObject(functionName, object, WebGLSharedObject::Ex clusive);
1855 }
1856
1857 bool WebGLRenderingContext::isAcquiredForReading(const char* functionName, WebGL SharedObject* object)
1858 {
1859 return validateWebGLSharedObject(functionName, object, WebGLSharedObject::Re adOnly);
1860 }
1861
1862 bool WebGLRenderingContext::validateWebGLSharedObject(const char* functionName, WebGLSharedObject* object, WebGLSharedObject::AcquireMode acquireMode)
1760 { 1863 {
1761 if (!object || !object->object()) { 1864 if (!object || !object->object()) {
1762 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob ject or object deleted"); 1865 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob ject or object deleted");
1763 return false; 1866 return false;
1764 } 1867 }
1765 if (!object->validate(contextGroup(), this)) { 1868 if (!object->validate(functionName, this, acquireMode, true, 0)) {
1766 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o bject does not belong to this context");
1767 return false; 1869 return false;
1768 } 1870 }
1769 return true; 1871 return true;
1770 } 1872 }
1771 1873
1874 long WebGLRenderingContext::acquireSharedResource(WebGLSharedObject* object, Web GLSharedObject::AcquireMode desiredMode, PassRefPtr<WebGLAcquireSharedResourceCa llback> callback, ExceptionCode& ec)
1875 {
1876 UNUSED_PARAM(ec);
1877 if (!object) {
1878 return 0;
1879 }
1880
1881 long id;
1882 if (!object->addAcquireRequest(this, desiredMode, callback, id)) {
1883 return 0;
1884 }
1885
1886 return id;
1887 }
1888
1889 void WebGLRenderingContext::releaseSharedResource(WebGLSharedObject* object, Exc eptionCode& ec)
1890 {
1891 UNUSED_PARAM(ec);
1892
1893 if (!object) {
1894 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "releaseSharedRe source", "no resource");
1895 return;
1896 }
1897
1898 if (!object->release(this)) {
1899 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "releaseSharedRe source", "resource not acquired");
1900 }
1901 }
1902
1903 void WebGLRenderingContext::cancelAcquireSharedResource(long id)
1904 {
1905 m_contextGroup->cancelAcquireSharedResource(this, id);
1906 }
1907
1772 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c ount, ExceptionCode& ec) 1908 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c ount, ExceptionCode& ec)
1773 { 1909 {
1774 UNUSED_PARAM(ec); 1910 UNUSED_PARAM(ec);
1775 1911
1776 if (!validateDrawArrays("drawArrays", mode, first, count)) 1912 if (!validateDrawArrays("drawArrays", mode, first, count))
1777 return; 1913 return;
1778 1914
1779 clearIfComposited(); 1915 bool texturesReplaced;
1780 1916 if (handleTextureCompleteness("drawArrays", true, &texturesReplaced)) {
1781 handleTextureCompleteness("drawArrays", true); 1917 clearIfComposited();
1782 m_context->drawArrays(mode, first, count); 1918 m_context->drawArrays(mode, first, count);
1783 handleTextureCompleteness("drawArrays", false); 1919 markContextChanged();
1784 markContextChanged(); 1920 }
1921 if (texturesReplaced) {
1922 handleTextureCompleteness("drawArrays", false, 0);
1923 }
1785 } 1924 }
1786 1925
1787 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denu m type, long long offset, ExceptionCode& ec) 1926 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denu m type, long long offset, ExceptionCode& ec)
1788 { 1927 {
1789 UNUSED_PARAM(ec); 1928 UNUSED_PARAM(ec);
1790 1929
1791 if (!validateDrawElements("drawElements", mode, count, type, offset)) 1930 if (!validateDrawElements("drawElements", mode, count, type, offset))
1792 return; 1931 return;
1793 1932
1794 clearIfComposited(); 1933 bool texturesReplaced;
1795 1934 if (handleTextureCompleteness("drawElements", true, &texturesReplaced)) {
1796 handleTextureCompleteness("drawElements", true); 1935 clearIfComposited();
1797 m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset)); 1936 m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offse t));
1798 handleTextureCompleteness("drawElements", false); 1937 markContextChanged();
1799 markContextChanged(); 1938 }
1939 if (texturesReplaced) {
1940 handleTextureCompleteness("drawElements", false, 0);
1941 }
1800 } 1942 }
1801 1943
1802 void WebGLRenderingContext::drawArraysInstancedANGLE(GC3Denum mode, GC3Dint firs t, GC3Dsizei count, GC3Dsizei primcount) 1944 void WebGLRenderingContext::drawArraysInstancedANGLE(GC3Denum mode, GC3Dint firs t, GC3Dsizei count, GC3Dsizei primcount)
1803 { 1945 {
1804 if (!validateDrawArrays("drawArraysInstancedANGLE", mode, first, count)) 1946 if (!validateDrawArrays("drawArraysInstancedANGLE", mode, first, count))
1805 return; 1947 return;
1806 1948
1807 if (!validateDrawInstanced("drawArraysInstancedANGLE", primcount)) 1949 if (!validateDrawInstanced("drawArraysInstancedANGLE", primcount))
1808 return; 1950 return;
1809 1951
1810 clearIfComposited(); 1952 bool texturesReplaced;
1811 1953 if (handleTextureCompleteness("drawArraysInstancedANGLE", true, &texturesRep laced)) {
1812 handleTextureCompleteness("drawArraysInstancedANGLE", true); 1954 clearIfComposited();
1813 m_context->getExtensions()->drawArraysInstancedANGLE(mode, first, count, pri mcount); 1955 m_context->getExtensions()->drawArraysInstancedANGLE(mode, first, count, primcount);
1814 handleTextureCompleteness("drawArraysInstancedANGLE", false); 1956 markContextChanged();
1815 markContextChanged(); 1957 }
1958 if (texturesReplaced) {
1959 handleTextureCompleteness("drawArraysInstancedANGLE", false, 0);
1960 }
1816 } 1961 }
1817 1962
1818 void WebGLRenderingContext::drawElementsInstancedANGLE(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) 1963 void WebGLRenderingContext::drawElementsInstancedANGLE(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
1819 { 1964 {
1820 if (!validateDrawElements("drawElementsInstancedANGLE", mode, count, type, o ffset)) 1965 if (!validateDrawElements("drawElementsInstancedANGLE", mode, count, type, o ffset))
1821 return; 1966 return;
1822 1967
1823 if (!validateDrawInstanced("drawElementsInstancedANGLE", primcount)) 1968 if (!validateDrawInstanced("drawElementsInstancedANGLE", primcount))
1824 return; 1969 return;
1825 1970
1826 clearIfComposited(); 1971 bool texturesReplaced;
1827 1972 if (handleTextureCompleteness("drawElementsInstancedANGLE", true, &texturesR eplaced)) {
1828 handleTextureCompleteness("drawElementsInstancedANGLE", true); 1973 clearIfComposited();
1829 m_context->getExtensions()->drawElementsInstancedANGLE(mode, count, type, st atic_cast<GC3Dintptr>(offset), primcount); 1974 m_context->getExtensions()->drawElementsInstancedANGLE(mode, count, type , static_cast<GC3Dintptr>(offset), primcount);
1830 handleTextureCompleteness("drawElementsInstancedANGLE", false); 1975 markContextChanged();
1831 markContextChanged(); 1976 }
1977 if (texturesReplaced) {
1978 handleTextureCompleteness("drawElementsInstancedANGLE", false, 0);
1979 }
1832 } 1980 }
1833 1981
1834 void WebGLRenderingContext::enable(GC3Denum cap) 1982 void WebGLRenderingContext::enable(GC3Denum cap)
1835 { 1983 {
1836 if (isContextLost() || !validateCapability("enable", cap)) 1984 if (isContextLost() || !validateCapability("enable", cap))
1837 return; 1985 return;
1838 if (cap == GraphicsContext3D::STENCIL_TEST) { 1986 if (cap == GraphicsContext3D::STENCIL_TEST) {
1839 m_stencilEnabled = true; 1987 m_stencilEnabled = true;
1840 applyStencilTest(); 1988 applyStencilTest();
1841 return; 1989 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 2027
1880 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode& ec) 2028 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode& ec)
1881 { 2029 {
1882 UNUSED_PARAM(ec); 2030 UNUSED_PARAM(ec);
1883 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) 2031 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment))
1884 return; 2032 return;
1885 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { 2033 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) {
1886 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf fer", "invalid target"); 2034 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf fer", "invalid target");
1887 return; 2035 return;
1888 } 2036 }
1889 if (buffer && !buffer->validate(contextGroup(), this)) { 2037 bool hasBeenBoundSinceLastAcquire;
1890 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no buffer or buffer not from this context"); 2038 if (buffer && !buffer->validate("framebufferRenderbuffer", this, WebGLShared Object::ReadOnly, false, &hasBeenBoundSinceLastAcquire)) {
1891 return; 2039 return;
1892 } 2040 }
1893 // Don't allow the default framebuffer to be mutated; all current 2041 // Don't allow the default framebuffer to be mutated; all current
1894 // implementations use an FBO internally in place of the default 2042 // implementations use an FBO internally in place of the default
1895 // FBO. 2043 // FBO.
1896 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2044 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
1897 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no framebuffer bound"); 2045 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no framebuffer bound");
1898 return; 2046 return;
1899 } 2047 }
1900 Platform3DObject bufferObject = objectOrZero(buffer); 2048 Platform3DObject bufferObject = objectOrZero(buffer);
2049 if (buffer && !hasBeenBoundSinceLastAcquire) {
2050 buffer->markAsBoundSinceLastAcquireForContext(this);
2051 }
1901 switch (attachment) { 2052 switch (attachment) {
1902 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 2053 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
1903 if (isDepthStencilSupported() || !buffer) { 2054 if (isDepthStencilSupported() || !buffer) {
1904 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ ATTACHMENT, renderbuffertarget, bufferObject); 2055 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ ATTACHMENT, renderbuffertarget, bufferObject);
1905 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI L_ATTACHMENT, renderbuffertarget, bufferObject); 2056 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI L_ATTACHMENT, renderbuffertarget, bufferObject);
1906 } else { 2057 } else {
1907 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer); 2058 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer);
1908 if (!emulatedStencilBuffer) { 2059 if (!emulatedStencilBuffer) {
1909 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "framebuffer Renderbuffer", "out of memory"); 2060 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "framebuffer Renderbuffer", "out of memory");
1910 return; 2061 return;
(...skipping 11 matching lines...) Expand all
1922 2073
1923 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode& ec) 2074 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode& ec)
1924 { 2075 {
1925 UNUSED_PARAM(ec); 2076 UNUSED_PARAM(ec);
1926 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) 2077 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment))
1927 return; 2078 return;
1928 if (level) { 2079 if (level) {
1929 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0"); 2080 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0");
1930 return; 2081 return;
1931 } 2082 }
1932 if (texture && !texture->validate(contextGroup(), this)) { 2083 bool hasBeenBoundSinceLastAcquire;
1933 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no texture or texture not from this context"); 2084 if (texture && !texture->validate("framebufferTexture2D", this, WebGLSharedO bject::ReadOnly, false, &hasBeenBoundSinceLastAcquire)) {
1934 return; 2085 return;
1935 } 2086 }
1936 // Don't allow the default framebuffer to be mutated; all current 2087 // Don't allow the default framebuffer to be mutated; all current
1937 // implementations use an FBO internally in place of the default 2088 // implementations use an FBO internally in place of the default
1938 // FBO. 2089 // FBO.
1939 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2090 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
1940 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no framebuffer bound"); 2091 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no framebuffer bound");
1941 return; 2092 return;
1942 } 2093 }
1943 Platform3DObject textureObject = objectOrZero(texture); 2094 Platform3DObject textureObject = objectOrZero(texture);
2095 if (texture && !hasBeenBoundSinceLastAcquire) {
2096 texture->markAsBoundSinceLastAcquireForContext(this);
2097 }
1944 switch (attachment) { 2098 switch (attachment) {
1945 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 2099 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
1946 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM ENT, textarget, textureObject, level); 2100 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM ENT, textarget, textureObject, level);
1947 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC HMENT, textarget, textureObject, level); 2101 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC HMENT, textarget, textureObject, level);
1948 break; 2102 break;
1949 case GraphicsContext3D::DEPTH_ATTACHMENT: 2103 case GraphicsContext3D::DEPTH_ATTACHMENT:
1950 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 2104 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
1951 break; 2105 break;
1952 case GraphicsContext3D::STENCIL_ATTACHMENT: 2106 case GraphicsContext3D::STENCIL_ATTACHMENT:
1953 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 2107 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
1954 break; 2108 break;
1955 default: 2109 default:
1956 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 2110 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
1957 } 2111 }
1958 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); 2112 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level);
1959 applyStencilTest(); 2113 applyStencilTest();
1960 } 2114 }
1961 2115
1962 void WebGLRenderingContext::frontFace(GC3Denum mode) 2116 void WebGLRenderingContext::frontFace(GC3Denum mode)
1963 { 2117 {
1964 if (isContextLost()) 2118 if (isContextLost())
1965 return; 2119 return;
1966 m_context->frontFace(mode); 2120 m_context->frontFace(mode);
1967 } 2121 }
1968 2122
1969 void WebGLRenderingContext::generateMipmap(GC3Denum target) 2123 void WebGLRenderingContext::generateMipmap(GC3Denum target)
1970 { 2124 {
1971 if (isContextLost()) 2125 if (isContextLost())
1972 return; 2126 return;
1973 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); 2127 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false, WebGLSharedObject::Exclusive);
1974 if (!tex) 2128 if (!tex)
1975 return; 2129 return;
1976 if (!tex->canGenerateMipmaps()) { 2130 if (!tex->canGenerateMipmaps()) {
1977 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap" , "level 0 not power of 2 or not all the same size"); 2131 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap" , "level 0 not power of 2 or not all the same size");
1978 return; 2132 return;
1979 } 2133 }
1980 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ et, 0))) 2134 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ et, 0)))
1981 return; 2135 return;
1982 2136
1983 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN EAR 2137 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN EAR
1984 // on Mac. Remove the hack once this driver bug is fixed. 2138 // on Mac. Remove the hack once this driver bug is fixed.
1985 #if OS(DARWIN) 2139 #if OS(DARWIN)
1986 bool needToResetMinFilter = false; 2140 bool needToResetMinFilter = false;
1987 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { 2141 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) {
1988 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST_MIPMAP_LINEAR); 2142 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST_MIPMAP_LINEAR);
1989 needToResetMinFilter = true; 2143 needToResetMinFilter = true;
1990 } 2144 }
1991 #endif 2145 #endif
1992 m_context->generateMipmap(target); 2146 m_context->generateMipmap(target);
1993 #if OS(DARWIN) 2147 #if OS(DARWIN)
1994 if (needToResetMinFilter) 2148 if (needToResetMinFilter)
1995 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, tex->getMinFilter()); 2149 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, tex->getMinFilter());
1996 #endif 2150 #endif
1997 tex->generateMipmapLevelInfo(); 2151 tex->generateMipmapLevelInfo();
1998 } 2152 }
1999 2153
2000 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index, ExceptionCode& ec) 2154 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index, ExceptionCode& ec)
2001 { 2155 {
2002 UNUSED_PARAM(ec); 2156 UNUSED_PARAM(ec);
2003 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) 2157 if (isContextLost() || !validateWebGLSharedObject("getActiveAttrib", program , WebGLSharedObject::ReadOnly))
2004 return 0; 2158 return 0;
2005 ActiveInfo info; 2159 ActiveInfo info;
2006 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) 2160 if (!m_context->getActiveAttrib(objectOrZero(program), index, info))
2007 return 0; 2161 return 0;
2008 return WebGLActiveInfo::create(info.name, info.type, info.size); 2162 return WebGLActiveInfo::create(info.name, info.type, info.size);
2009 } 2163 }
2010 2164
2011 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram * program, GC3Duint index, ExceptionCode& ec) 2165 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram * program, GC3Duint index, ExceptionCode& ec)
2012 { 2166 {
2013 UNUSED_PARAM(ec); 2167 UNUSED_PARAM(ec);
2014 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) 2168 if (isContextLost() || !validateWebGLSharedObject("getActiveUniform", progra m, WebGLSharedObject::ReadOnly))
2015 return 0; 2169 return 0;
2016 ActiveInfo info; 2170 ActiveInfo info;
2017 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) 2171 if (!m_context->getActiveUniform(objectOrZero(program), index, info))
2018 return 0; 2172 return 0;
2019 return WebGLActiveInfo::create(info.name, info.type, info.size); 2173 return WebGLActiveInfo::create(info.name, info.type, info.size);
2020 } 2174 }
2021 2175
2022 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref Ptr<WebGLShader> >& shaderObjects, ExceptionCode& ec) 2176 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref Ptr<WebGLShader> >& shaderObjects, ExceptionCode& ec)
2023 { 2177 {
2024 UNUSED_PARAM(ec); 2178 UNUSED_PARAM(ec);
2025 shaderObjects.clear(); 2179 shaderObjects.clear();
2026 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) 2180 if (isContextLost() || !validateWebGLSharedObject("getAttachedShaders", prog ram, WebGLSharedObject::ReadOnly))
2027 return false; 2181 return false;
2028 2182
2029 const GC3Denum shaderType[] = { 2183 const GC3Denum shaderType[] = {
2030 GraphicsContext3D::VERTEX_SHADER, 2184 GraphicsContext3D::VERTEX_SHADER,
2031 GraphicsContext3D::FRAGMENT_SHADER 2185 GraphicsContext3D::FRAGMENT_SHADER
2032 }; 2186 };
2033 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { 2187 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) {
2034 WebGLShader* shader = program->getAttachedShader(shaderType[i]); 2188 WebGLShader* shader = program->getAttachedShader(shaderType[i]);
2035 if (shader) 2189 if (shader)
2036 shaderObjects.append(shader); 2190 shaderObjects.append(shader);
2037 } 2191 }
2038 return true; 2192 return true;
2039 } 2193 }
2040 2194
2041 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St ring& name) 2195 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St ring& name)
2042 { 2196 {
2043 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) 2197 if (isContextLost() || !validateWebGLSharedObject("getAttribLocation", progr am, WebGLSharedObject::ReadOnly))
2044 return -1; 2198 return -1;
2045 if (!validateLocationLength("getAttribLocation", name)) 2199 if (!validateLocationLength("getAttribLocation", name))
2046 return -1; 2200 return -1;
2047 if (!validateString("getAttribLocation", name)) 2201 if (!validateString("getAttribLocation", name))
2048 return -1; 2202 return -1;
2049 if (isPrefixReserved(name)) 2203 if (isPrefixReserved(name))
2050 return -1; 2204 return -1;
2051 if (!program->getLinkStatus()) { 2205 if (!program->getLinkStatus(this)) {
2052 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati on", "program not linked"); 2206 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati on", "program not linked");
2053 return 0; 2207 return 0;
2054 } 2208 }
2055 return m_context->getAttribLocation(objectOrZero(program), name); 2209 return m_context->getAttribLocation(objectOrZero(program), name);
2056 } 2210 }
2057 2211
2058 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode& ec) 2212 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode& ec)
2059 { 2213 {
2060 UNUSED_PARAM(ec); 2214 UNUSED_PARAM(ec);
2061 if (isContextLost()) 2215 if (isContextLost())
2062 return WebGLGetInfo(); 2216 return WebGLGetInfo();
2063 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D ::ELEMENT_ARRAY_BUFFER) { 2217
2064 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid target"); 2218 WebGLBuffer* buffer = getBufferForTarget("getBufferParameter", target);
2219 if (!buffer) {
2065 return WebGLGetInfo(); 2220 return WebGLGetInfo();
2066 } 2221 }
2067 2222
2068 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B UFFER_USAGE) { 2223 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B UFFER_USAGE) {
2069 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid parameter name"); 2224 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid parameter name");
2070 return WebGLGetInfo(); 2225 return WebGLGetInfo();
2071 } 2226 }
2072 2227
2228 if (!isAcquiredForReading("getBufferParameter", buffer)) {
2229 return WebGLGetInfo();
2230 }
2231
2073 GC3Dint value = 0; 2232 GC3Dint value = 0;
2074 m_context->getBufferParameteriv(target, pname, &value); 2233 m_context->getBufferParameteriv(target, pname, &value);
2075 if (pname == GraphicsContext3D::BUFFER_SIZE) 2234 if (pname == GraphicsContext3D::BUFFER_SIZE)
2076 return WebGLGetInfo(value); 2235 return WebGLGetInfo(value);
2077 return WebGLGetInfo(static_cast<unsigned int>(value)); 2236 return WebGLGetInfo(static_cast<unsigned int>(value));
2078 } 2237 }
2079 2238
2080 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() 2239 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes()
2081 { 2240 {
2082 if (isContextLost()) 2241 if (isContextLost())
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 return WebGLGetInfo(value); 2590 return WebGLGetInfo(value);
2432 } 2591 }
2433 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name"); 2592 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name");
2434 return WebGLGetInfo(); 2593 return WebGLGetInfo();
2435 } 2594 }
2436 } 2595 }
2437 2596
2438 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G C3Denum pname, ExceptionCode& ec) 2597 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G C3Denum pname, ExceptionCode& ec)
2439 { 2598 {
2440 UNUSED_PARAM(ec); 2599 UNUSED_PARAM(ec);
2441 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) 2600 if (isContextLost() || !validateWebGLSharedObject("getProgramParameter", pro gram, WebGLSharedObject::ReadOnly))
2442 return WebGLGetInfo(); 2601 return WebGLGetInfo();
2443 2602
2444 GC3Dint value = 0; 2603 GC3Dint value = 0;
2445 switch (pname) { 2604 switch (pname) {
2446 case GraphicsContext3D::DELETE_STATUS: 2605 case GraphicsContext3D::DELETE_STATUS:
2447 return WebGLGetInfo(program->isDeleted()); 2606 return WebGLGetInfo(program->isDeleted());
2448 case GraphicsContext3D::VALIDATE_STATUS: 2607 case GraphicsContext3D::VALIDATE_STATUS:
2449 m_context->getProgramiv(objectOrZero(program), pname, &value); 2608 m_context->getProgramiv(objectOrZero(program), pname, &value);
2450 return WebGLGetInfo(static_cast<bool>(value)); 2609 return WebGLGetInfo(static_cast<bool>(value));
2451 case GraphicsContext3D::LINK_STATUS: 2610 case GraphicsContext3D::LINK_STATUS:
2452 return WebGLGetInfo(program->getLinkStatus()); 2611 return WebGLGetInfo(program->getLinkStatus(this));
2453 case GraphicsContext3D::ATTACHED_SHADERS: 2612 case GraphicsContext3D::ATTACHED_SHADERS:
2454 case GraphicsContext3D::ACTIVE_ATTRIBUTES: 2613 case GraphicsContext3D::ACTIVE_ATTRIBUTES:
2455 case GraphicsContext3D::ACTIVE_UNIFORMS: 2614 case GraphicsContext3D::ACTIVE_UNIFORMS:
2456 m_context->getProgramiv(objectOrZero(program), pname, &value); 2615 m_context->getProgramiv(objectOrZero(program), pname, &value);
2457 return WebGLGetInfo(value); 2616 return WebGLGetInfo(value);
2458 default: 2617 default:
2459 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter" , "invalid parameter name"); 2618 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter" , "invalid parameter name");
2460 return WebGLGetInfo(); 2619 return WebGLGetInfo();
2461 } 2620 }
2462 } 2621 }
2463 2622
2464 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, Exception Code& ec) 2623 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, Exception Code& ec)
2465 { 2624 {
2466 UNUSED_PARAM(ec); 2625 UNUSED_PARAM(ec);
2467 if (isContextLost()) 2626 if (isContextLost())
2468 return String(); 2627 return String();
2469 if (!validateWebGLObject("getProgramInfoLog", program)) 2628 if (!validateWebGLSharedObject("getProgramInfoLog", program, WebGLSharedObje ct::ReadOnly))
2470 return ""; 2629 return "";
2471 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); 2630 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program)));
2472 } 2631 }
2473 2632
2474 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC 3Denum pname, ExceptionCode& ec) 2633 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC 3Denum pname, ExceptionCode& ec)
2475 { 2634 {
2476 UNUSED_PARAM(ec); 2635 UNUSED_PARAM(ec);
2477 if (isContextLost()) 2636 if (isContextLost())
2478 return WebGLGetInfo(); 2637 return WebGLGetInfo();
2479 if (target != GraphicsContext3D::RENDERBUFFER) { 2638 if (target != GraphicsContext3D::RENDERBUFFER) {
2480 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid target"); 2639 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid target");
2481 return WebGLGetInfo(); 2640 return WebGLGetInfo();
2482 } 2641 }
2483 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 2642 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) {
2484 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer Parameter", "no renderbuffer bound"); 2643 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer Parameter", "no renderbuffer bound");
2485 return WebGLGetInfo(); 2644 return WebGLGetInfo();
2486 } 2645 }
2487 2646
2647 if (!isAcquiredForReading("getRenderbufferParameter", m_renderbufferBinding. get())) {
2648 return WebGLGetInfo();
2649 }
2650
2488 GC3Dint value = 0; 2651 GC3Dint value = 0;
2489 switch (pname) { 2652 switch (pname) {
2490 case GraphicsContext3D::RENDERBUFFER_WIDTH: 2653 case GraphicsContext3D::RENDERBUFFER_WIDTH:
2491 case GraphicsContext3D::RENDERBUFFER_HEIGHT: 2654 case GraphicsContext3D::RENDERBUFFER_HEIGHT:
2492 case GraphicsContext3D::RENDERBUFFER_RED_SIZE: 2655 case GraphicsContext3D::RENDERBUFFER_RED_SIZE:
2493 case GraphicsContext3D::RENDERBUFFER_GREEN_SIZE: 2656 case GraphicsContext3D::RENDERBUFFER_GREEN_SIZE:
2494 case GraphicsContext3D::RENDERBUFFER_BLUE_SIZE: 2657 case GraphicsContext3D::RENDERBUFFER_BLUE_SIZE:
2495 case GraphicsContext3D::RENDERBUFFER_ALPHA_SIZE: 2658 case GraphicsContext3D::RENDERBUFFER_ALPHA_SIZE:
2496 case GraphicsContext3D::RENDERBUFFER_DEPTH_SIZE: 2659 case GraphicsContext3D::RENDERBUFFER_DEPTH_SIZE:
2497 m_context->getRenderbufferParameteriv(target, pname, &value); 2660 m_context->getRenderbufferParameteriv(target, pname, &value);
(...skipping 11 matching lines...) Expand all
2509 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); 2672 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat());
2510 default: 2673 default:
2511 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid parameter name"); 2674 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid parameter name");
2512 return WebGLGetInfo(); 2675 return WebGLGetInfo();
2513 } 2676 }
2514 } 2677 }
2515 2678
2516 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D enum pname, ExceptionCode& ec) 2679 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D enum pname, ExceptionCode& ec)
2517 { 2680 {
2518 UNUSED_PARAM(ec); 2681 UNUSED_PARAM(ec);
2519 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) 2682 if (isContextLost() || !validateWebGLSharedObject("getShaderParameter", shad er, WebGLSharedObject::ReadOnly))
2520 return WebGLGetInfo(); 2683 return WebGLGetInfo();
2521 GC3Dint value = 0; 2684 GC3Dint value = 0;
2522 switch (pname) { 2685 switch (pname) {
2523 case GraphicsContext3D::DELETE_STATUS: 2686 case GraphicsContext3D::DELETE_STATUS:
2524 return WebGLGetInfo(shader->isDeleted()); 2687 return WebGLGetInfo(shader->isDeleted());
2525 case GraphicsContext3D::COMPILE_STATUS: 2688 case GraphicsContext3D::COMPILE_STATUS:
2526 m_context->getShaderiv(objectOrZero(shader), pname, &value); 2689 m_context->getShaderiv(objectOrZero(shader), pname, &value);
2527 return WebGLGetInfo(static_cast<bool>(value)); 2690 return WebGLGetInfo(static_cast<bool>(value));
2528 case GraphicsContext3D::SHADER_TYPE: 2691 case GraphicsContext3D::SHADER_TYPE:
2529 m_context->getShaderiv(objectOrZero(shader), pname, &value); 2692 m_context->getShaderiv(objectOrZero(shader), pname, &value);
2530 return WebGLGetInfo(static_cast<unsigned int>(value)); 2693 return WebGLGetInfo(static_cast<unsigned int>(value));
2531 default: 2694 default:
2532 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name"); 2695 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name");
2533 return WebGLGetInfo(); 2696 return WebGLGetInfo();
2534 } 2697 }
2535 } 2698 }
2536 2699
2537 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCod e& ec) 2700 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCod e& ec)
2538 { 2701 {
2539 UNUSED_PARAM(ec); 2702 UNUSED_PARAM(ec);
2540 if (isContextLost()) 2703 if (isContextLost())
2541 return String(); 2704 return String();
2542 if (!validateWebGLObject("getShaderInfoLog", shader)) 2705 if (!validateWebGLSharedObject("getShaderInfoLog", shader, WebGLSharedObject ::ReadOnly))
2543 return ""; 2706 return "";
2544 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); 2707 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader)));
2545 } 2708 }
2546 2709
2547 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision Format(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode& ec) 2710 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision Format(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode& ec)
2548 { 2711 {
2549 UNUSED_PARAM(ec); 2712 UNUSED_PARAM(ec);
2550 if (isContextLost()) 2713 if (isContextLost())
2551 return 0; 2714 return 0;
2552 switch (shaderType) { 2715 switch (shaderType) {
(...skipping 21 matching lines...) Expand all
2574 GC3Dint precision = 0; 2737 GC3Dint precision = 0;
2575 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci sion); 2738 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci sion);
2576 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); 2739 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision);
2577 } 2740 }
2578 2741
2579 String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode & ec) 2742 String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode & ec)
2580 { 2743 {
2581 UNUSED_PARAM(ec); 2744 UNUSED_PARAM(ec);
2582 if (isContextLost()) 2745 if (isContextLost())
2583 return String(); 2746 return String();
2584 if (!validateWebGLObject("getShaderSource", shader)) 2747 if (!validateWebGLSharedObject("getShaderSource", shader, WebGLSharedObject: :ReadOnly))
2585 return ""; 2748 return "";
2586 return ensureNotNull(shader->getSource()); 2749 return ensureNotNull(shader->getSource());
2587 } 2750 }
2588 2751
2589 Vector<String> WebGLRenderingContext::getSupportedExtensions() 2752 Vector<String> WebGLRenderingContext::getSupportedExtensions()
2590 { 2753 {
2591 Vector<String> result; 2754 Vector<String> result;
2592 if (isContextLost()) 2755 if (isContextLost())
2593 return result; 2756 return result;
2594 2757
2595 for (size_t i = 0; i < m_extensions.size(); ++i) { 2758 for (size_t i = 0; i < m_extensions.size(); ++i) {
2596 ExtensionTracker* tracker = m_extensions[i]; 2759 ExtensionTracker* tracker = m_extensions[i];
2597 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) 2760 if (tracker->getPrivileged() && !allowPrivilegedExtensions())
2598 continue; 2761 continue;
2599 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtensions Enabled()) 2762 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtensions Enabled())
2600 continue; 2763 continue;
2601 if (tracker->supported(this)) 2764 if (tracker->supported(this))
2602 result.append(String(tracker->getPrefixed() ? "WEBKIT_" : "") + tra cker->getExtensionName()); 2765 result.append(String(tracker->getPrefixed() ? "WEBKIT_" : "") + tra cker->getExtensionName());
2603 } 2766 }
2604 2767
2605 return result; 2768 return result;
2606 } 2769 }
2607 2770
2608 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn ame, ExceptionCode& ec) 2771 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn ame, ExceptionCode& ec)
2609 { 2772 {
2610 UNUSED_PARAM(ec); 2773 UNUSED_PARAM(ec);
2611 if (isContextLost()) 2774 if (isContextLost())
2612 return WebGLGetInfo(); 2775 return WebGLGetInfo();
2613 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ; 2776 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false, WebGLSharedObject::ReadOnly);
2614 if (!tex) 2777 if (!tex)
2615 return WebGLGetInfo(); 2778 return WebGLGetInfo();
2616 GC3Dint value = 0; 2779 GC3Dint value = 0;
2617 switch (pname) { 2780 switch (pname) {
2618 case GraphicsContext3D::TEXTURE_MAG_FILTER: 2781 case GraphicsContext3D::TEXTURE_MAG_FILTER:
2619 case GraphicsContext3D::TEXTURE_MIN_FILTER: 2782 case GraphicsContext3D::TEXTURE_MIN_FILTER:
2620 case GraphicsContext3D::TEXTURE_WRAP_S: 2783 case GraphicsContext3D::TEXTURE_WRAP_S:
2621 case GraphicsContext3D::TEXTURE_WRAP_T: 2784 case GraphicsContext3D::TEXTURE_WRAP_T:
2622 m_context->getTexParameteriv(target, pname, &value); 2785 m_context->getTexParameteriv(target, pname, &value);
2623 return WebGLGetInfo(static_cast<unsigned int>(value)); 2786 return WebGLGetInfo(static_cast<unsigned int>(value));
2624 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic 2787 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic
2625 if (m_extTextureFilterAnisotropic) { 2788 if (m_extTextureFilterAnisotropic) {
2626 m_context->getTexParameteriv(target, pname, &value); 2789 m_context->getTexParameteriv(target, pname, &value);
2627 return WebGLGetInfo(static_cast<unsigned int>(value)); 2790 return WebGLGetInfo(static_cast<unsigned int>(value));
2628 } 2791 }
2629 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); 2792 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name, EXT_texture_filter_anisotropic not enabled");
2630 return WebGLGetInfo(); 2793 return WebGLGetInfo();
2631 default: 2794 default:
2632 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name"); 2795 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name");
2633 return WebGLGetInfo(); 2796 return WebGLGetInfo();
2634 } 2797 }
2635 } 2798 }
2636 2799
2637 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG LUniformLocation* uniformLocation, ExceptionCode& ec) 2800 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG LUniformLocation* uniformLocation, ExceptionCode& ec)
2638 { 2801 {
2639 UNUSED_PARAM(ec); 2802 UNUSED_PARAM(ec);
2640 if (isContextLost() || !validateWebGLObject("getUniform", program)) 2803 if (isContextLost() || !validateWebGLSharedObject("getUniform", program, Web GLSharedObject::ReadOnly))
2641 return WebGLGetInfo(); 2804 return WebGLGetInfo();
2642 if (!uniformLocation || uniformLocation->program() != program) { 2805 if (!uniformLocation || uniformLocation->program() != program) {
2643 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n o uniformlocation or not valid for this program"); 2806 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n o uniformlocation or not valid for this program");
2644 return WebGLGetInfo(); 2807 return WebGLGetInfo();
2645 } 2808 }
2646 GC3Dint location = uniformLocation->location(); 2809 GC3Dint location = uniformLocation->location();
2647 2810
2648 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it 2811 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it
2649 GC3Dint activeUniforms = 0; 2812 GC3Dint activeUniforms = 0;
2650 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNI FORMS, &activeUniforms); 2813 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNI FORMS, &activeUniforms);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 } 2936 }
2774 } 2937 }
2775 // If we get here, something went wrong in our unfortunately complex logic a bove 2938 // If we get here, something went wrong in our unfortunately complex logic a bove
2776 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e rror"); 2939 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e rror");
2777 return WebGLGetInfo(); 2940 return WebGLGetInfo();
2778 } 2941 }
2779 2942
2780 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL Program* program, const String& name, ExceptionCode& ec) 2943 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL Program* program, const String& name, ExceptionCode& ec)
2781 { 2944 {
2782 UNUSED_PARAM(ec); 2945 UNUSED_PARAM(ec);
2783 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) 2946 if (isContextLost() || !validateWebGLSharedObject("getUniformLocation", prog ram, WebGLSharedObject::ReadOnly))
2784 return 0; 2947 return 0;
2785 if (!validateLocationLength("getUniformLocation", name)) 2948 if (!validateLocationLength("getUniformLocation", name))
2786 return 0; 2949 return 0;
2787 if (!validateString("getUniformLocation", name)) 2950 if (!validateString("getUniformLocation", name))
2788 return 0; 2951 return 0;
2789 if (isPrefixReserved(name)) 2952 if (isPrefixReserved(name))
2790 return 0; 2953 return 0;
2791 if (!program->getLinkStatus()) { 2954 if (!program->getLinkStatus(this)) {
2792 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat ion", "program not linked"); 2955 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat ion", "program not linked");
2793 return 0; 2956 return 0;
2794 } 2957 }
2795 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program ), name); 2958 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program ), name);
2796 if (uniformLocation == -1) 2959 if (uniformLocation == -1)
2797 return 0; 2960 return 0;
2798 return WebGLUniformLocation::create(program, uniformLocation); 2961 return WebGLUniformLocation::create(program, uniformLocation);
2799 } 2962 }
2800 2963
2801 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna me, ExceptionCode& ec) 2964 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna me, ExceptionCode& ec)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 { 3031 {
2869 if (!buffer || isContextLost()) 3032 if (!buffer || isContextLost())
2870 return 0; 3033 return 0;
2871 3034
2872 if (!buffer->hasEverBeenBound()) 3035 if (!buffer->hasEverBeenBound())
2873 return 0; 3036 return 0;
2874 3037
2875 return m_context->isBuffer(buffer->object()); 3038 return m_context->isBuffer(buffer->object());
2876 } 3039 }
2877 3040
2878 bool WebGLRenderingContext::isContextLost() 3041 bool WebGLRenderingContext::isContextLost() const
2879 { 3042 {
2880 return m_contextLost; 3043 return m_contextLost;
2881 } 3044 }
2882 3045
2883 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) 3046 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap)
2884 { 3047 {
2885 if (isContextLost() || !validateCapability("isEnabled", cap)) 3048 if (isContextLost() || !validateCapability("isEnabled", cap))
2886 return 0; 3049 return 0;
2887 if (cap == GraphicsContext3D::STENCIL_TEST) 3050 if (cap == GraphicsContext3D::STENCIL_TEST)
2888 return m_stencilEnabled; 3051 return m_stencilEnabled;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 void WebGLRenderingContext::lineWidth(GC3Dfloat width) 3104 void WebGLRenderingContext::lineWidth(GC3Dfloat width)
2942 { 3105 {
2943 if (isContextLost()) 3106 if (isContextLost())
2944 return; 3107 return;
2945 m_context->lineWidth(width); 3108 m_context->lineWidth(width);
2946 } 3109 }
2947 3110
2948 void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec ) 3111 void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec )
2949 { 3112 {
2950 UNUSED_PARAM(ec); 3113 UNUSED_PARAM(ec);
2951 if (isContextLost() || !validateWebGLObject("linkProgram", program)) 3114 if (isContextLost() || !validateWebGLSharedObject("linkProgram", program, We bGLSharedObject::Exclusive))
2952 return; 3115 return;
2953 3116
2954 m_context->linkProgram(objectOrZero(program)); 3117 m_context->linkProgram(objectOrZero(program));
2955 program->increaseLinkCount(); 3118 program->increaseLinkCount();
2956 } 3119 }
2957 3120
2958 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) 3121 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param)
2959 { 3122 {
2960 if (isContextLost()) 3123 if (isContextLost())
2961 return; 3124 return;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED _BYTE) { 3197 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED _BYTE) {
3035 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "f ormat not RGBA or type not UNSIGNED_BYTE"); 3198 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "f ormat not RGBA or type not UNSIGNED_BYTE");
3036 return; 3199 return;
3037 } 3200 }
3038 // Validate array type against pixel type. 3201 // Validate array type against pixel type.
3039 if (pixels->getType() != ArrayBufferView::TypeUint8) { 3202 if (pixels->getType() != ArrayBufferView::TypeUint8) {
3040 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not Uint8Array"); 3203 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not Uint8Array");
3041 return; 3204 return;
3042 } 3205 }
3043 const char* reason = "framebuffer incomplete"; 3206 const char* reason = "framebuffer incomplete";
3044 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 3207 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare dObject::ReadOnly, &reason)) {
3045 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea dPixels", reason); 3208 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea dPixels", reason);
3046 return; 3209 return;
3047 } 3210 }
3048 // Calculate array size, taking into consideration of PACK_ALIGNMENT. 3211 // Calculate array size, taking into consideration of PACK_ALIGNMENT.
3049 unsigned int totalBytesRequired = 0; 3212 unsigned int totalBytesRequired = 0;
3050 unsigned int padding = 0; 3213 unsigned int padding = 0;
3051 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_packAlignment, &totalBytesRequired, &padding); 3214 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_packAlignment, &totalBytesRequired, &padding);
3052 if (error != GraphicsContext3D::NO_ERROR) { 3215 if (error != GraphicsContext3D::NO_ERROR) {
3053 synthesizeGLError(error, "readPixels", "invalid dimensions"); 3216 synthesizeGLError(error, "readPixels", "invalid dimensions");
3054 return; 3217 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3087 if (isContextLost()) 3250 if (isContextLost())
3088 return; 3251 return;
3089 if (target != GraphicsContext3D::RENDERBUFFER) { 3252 if (target != GraphicsContext3D::RENDERBUFFER) {
3090 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid target"); 3253 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid target");
3091 return; 3254 return;
3092 } 3255 }
3093 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 3256 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) {
3094 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto rage", "no bound renderbuffer"); 3257 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto rage", "no bound renderbuffer");
3095 return; 3258 return;
3096 } 3259 }
3260 if (!isAcquiredForModification("renderbufferStorage", m_renderbufferBinding. get()))
3261 return;
3097 if (!validateSize("renderbufferStorage", width, height)) 3262 if (!validateSize("renderbufferStorage", width, height))
3098 return; 3263 return;
3099 switch (internalformat) { 3264 switch (internalformat) {
3100 case GraphicsContext3D::DEPTH_COMPONENT16: 3265 case GraphicsContext3D::DEPTH_COMPONENT16:
3101 case GraphicsContext3D::RGBA4: 3266 case GraphicsContext3D::RGBA4:
3102 case GraphicsContext3D::RGB5_A1: 3267 case GraphicsContext3D::RGB5_A1:
3103 case GraphicsContext3D::RGB565: 3268 case GraphicsContext3D::RGB565:
3104 case GraphicsContext3D::STENCIL_INDEX8: 3269 case GraphicsContext3D::STENCIL_INDEX8:
3105 m_context->renderbufferStorage(target, internalformat, width, height); 3270 m_context->renderbufferStorage(target, internalformat, width, height);
3106 m_renderbufferBinding->setInternalFormat(internalformat); 3271 m_renderbufferBinding->setInternalFormat(internalformat);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 if (isContextLost()) 3310 if (isContextLost())
3146 return; 3311 return;
3147 if (!validateSize("scissor", width, height)) 3312 if (!validateSize("scissor", width, height))
3148 return; 3313 return;
3149 m_context->scissor(x, y, width, height); 3314 m_context->scissor(x, y, width, height);
3150 } 3315 }
3151 3316
3152 void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri ng, ExceptionCode& ec) 3317 void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri ng, ExceptionCode& ec)
3153 { 3318 {
3154 UNUSED_PARAM(ec); 3319 UNUSED_PARAM(ec);
3155 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) 3320 if (isContextLost() || !validateWebGLSharedObject("shaderSource", shader, We bGLSharedObject::Exclusive))
3156 return; 3321 return;
3157 String stringWithoutComments = StripComments(string).result(); 3322 String stringWithoutComments = StripComments(string).result();
3158 if (!validateString("shaderSource", stringWithoutComments)) 3323 if (!validateString("shaderSource", stringWithoutComments))
3159 return; 3324 return;
3160 shader->setSource(string); 3325 shader->setSource(string);
3161 m_context->shaderSource(objectOrZero(shader), stringWithoutComments); 3326 m_context->shaderSource(objectOrZero(shader), stringWithoutComments);
3162 } 3327 }
3163 3328
3164 void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mas k) 3329 void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mas k)
3165 { 3330 {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 if (isContextLost()) 3410 if (isContextLost())
3246 return; 3411 return;
3247 m_context->stencilOpSeparate(face, fail, zfail, zpass); 3412 m_context->stencilOpSeparate(face, fail, zfail, zpass);
3248 } 3413 }
3249 3414
3250 void WebGLRenderingContext::texImage2DBase(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode& ec) 3415 void WebGLRenderingContext::texImage2DBase(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode& ec)
3251 { 3416 {
3252 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 3417 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
3253 // FIXME: For now we ignore any errors returned 3418 // FIXME: For now we ignore any errors returned
3254 ec = 0; 3419 ec = 0;
3255 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); 3420 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true, WebGL SharedObject::Exclusive);
3256 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev el, internalformat, width, height, border, format, type)); 3421 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev el, internalformat, width, height, border, format, type));
3257 ASSERT(tex); 3422 ASSERT(tex);
3258 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); 3423 ASSERT(!level || !WebGLTexture::isNPOT(width, height));
3259 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); 3424 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat));
3260 m_context->texImage2D(target, level, internalformat, width, height, 3425 m_context->texImage2D(target, level, internalformat, width, height,
3261 border, format, type, pixels); 3426 border, format, type, pixels);
3262 tex->setLevelInfo(target, level, internalformat, width, height, type); 3427 tex->setLevelInfo(target, level, internalformat, width, height, type);
3263 } 3428 }
3264 3429
3265 void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContex t3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionC ode& ec) 3430 void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContex t3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionC ode& ec)
(...skipping 25 matching lines...) Expand all
3291 texImage2DBase(target, level, internalformat, image->width(), image->height( ), 0, format, type, needConversion ? data.data() : imagePixelData, ec); 3456 texImage2DBase(target, level, internalformat, image->width(), image->height( ), 0, format, type, needConversion ? data.data() : imagePixelData, ec);
3292 if (m_unpackAlignment != 1) 3457 if (m_unpackAlignment != 1)
3293 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3458 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment);
3294 } 3459 }
3295 3460
3296 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) 3461 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)
3297 { 3462 {
3298 if (!validateTexFuncParameters(functionName, functionType, target, level, in ternalformat, width, height, border, format, type)) 3463 if (!validateTexFuncParameters(functionName, functionType, target, level, in ternalformat, width, height, border, format, type))
3299 return false; 3464 return false;
3300 3465
3301 WebGLTexture* texture = validateTextureBinding(functionName, target, true); 3466 WebGLTexture* texture = validateTextureBinding(functionName, target, true, W ebGLSharedObject::Exclusive);
3302 if (!texture) 3467 if (!texture)
3303 return false; 3468 return false;
3304 3469
3305 if (functionType == NotTexSubImage2D) { 3470 if (functionType == NotTexSubImage2D) {
3306 if (level && WebGLTexture::isNPOT(width, height)) { 3471 if (level && WebGLTexture::isNPOT(width, height)) {
3307 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel > 0 not power of 2"); 3472 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel > 0 not power of 2");
3308 return false; 3473 return false;
3309 } 3474 }
3310 // For SourceArrayBufferView, function validateTexFuncData() would handl e whether to validate the SettableTexFormat 3475 // For SourceArrayBufferView, function validateTexFuncData() would handl e whether to validate the SettableTexFormat
3311 // by checking if the ArrayBufferView is null or not. 3476 // by checking if the ArrayBufferView is null or not.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3402 texImage2DImpl(target, level, internalformat, format, type, imageForRender, GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); 3567 texImage2DImpl(target, level, internalformat, format, type, imageForRender, GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
3403 } 3568 }
3404 3569
3405 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3570 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3406 GC3Denum format, GC3Denum type, HTMLCanva sElement* canvas, ExceptionCode& ec) 3571 GC3Denum format, GC3Denum type, HTMLCanva sElement* canvas, ExceptionCode& ec)
3407 { 3572 {
3408 ec = 0; 3573 ec = 0;
3409 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, ec) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvasElement, tar get, level, internalformat, canvas->width(), canvas->height(), 0, format, type, 0, 0)) 3574 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, ec) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvasElement, tar get, level, internalformat, canvas->width(), canvas->height(), 0, format, type, 0, 0))
3410 return; 3575 return;
3411 3576
3412 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3577 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true, W ebGLSharedObject::Exclusive);
3413 // If possible, copy from the canvas element directly to the texture 3578 // If possible, copy from the canvas element directly to the texture
3414 // via the GPU, without a read-back to system memory. 3579 // via the GPU, without a read-back to system memory.
3415 if (GraphicsContext3D::TEXTURE_2D == target && texture) { 3580 if (GraphicsContext3D::TEXTURE_2D == target && texture) {
3416 ImageBuffer* buffer = canvas->buffer(); 3581 ImageBuffer* buffer = canvas->buffer();
3417 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->o bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3582 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->o bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3418 texture->setLevelInfo(target, level, internalformat, canvas->width() , canvas->height(), type); 3583 texture->setLevelInfo(target, level, internalformat, canvas->width() , canvas->height(), type);
3419 return; 3584 return;
3420 } 3585 }
3421 } 3586 }
3422 3587
(...skipping 21 matching lines...) Expand all
3444 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3609 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3445 GC3Denum format, GC3Denum type, HTMLVideo Element* video, ExceptionCode& ec) 3610 GC3Denum format, GC3Denum type, HTMLVideo Element* video, ExceptionCode& ec)
3446 { 3611 {
3447 ec = 0; 3612 ec = 0;
3448 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, ec) 3613 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, ec)
3449 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) 3614 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0))
3450 return; 3615 return;
3451 3616
3452 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. 3617 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
3453 // Otherwise, it will fall back to the normal SW path. 3618 // Otherwise, it will fall back to the normal SW path.
3454 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3619 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true, W ebGLSharedObject::Exclusive);
3455 if (GraphicsContext3D::TEXTURE_2D == target && texture) { 3620 if (GraphicsContext3D::TEXTURE_2D == target && texture) {
3456 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3621 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3457 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type); 3622 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type);
3458 return; 3623 return;
3459 } 3624 }
3460 } 3625 }
3461 3626
3462 // Normal pure SW path. 3627 // Normal pure SW path.
3463 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e(), ec); 3628 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e(), ec);
3464 if (!image) 3629 if (!image)
3465 return; 3630 return;
3466 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); 3631 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
3467 } 3632 }
3468 3633
3469 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl oat paramf, GC3Dint parami, bool isFloat) 3634 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl oat paramf, GC3Dint parami, bool isFloat)
3470 { 3635 {
3471 if (isContextLost()) 3636 if (isContextLost())
3472 return; 3637 return;
3473 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); 3638 WebGLTexture* tex = validateTextureBinding("texParameter", target, false, We bGLSharedObject::Exclusive);
3474 if (!tex) 3639 if (!tex)
3475 return; 3640 return;
3476 switch (pname) { 3641 switch (pname) {
3477 case GraphicsContext3D::TEXTURE_MIN_FILTER: 3642 case GraphicsContext3D::TEXTURE_MIN_FILTER:
3478 case GraphicsContext3D::TEXTURE_MAG_FILTER: 3643 case GraphicsContext3D::TEXTURE_MAG_FILTER:
3479 break; 3644 break;
3480 case GraphicsContext3D::TEXTURE_WRAP_S: 3645 case GraphicsContext3D::TEXTURE_WRAP_S:
3481 case GraphicsContext3D::TEXTURE_WRAP_T: 3646 case GraphicsContext3D::TEXTURE_WRAP_T:
3482 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) 3647 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT)
3483 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT)) { 3648 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3515 } 3680 }
3516 3681
3517 void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum form at, GC3Denum type, const void* pixels, ExceptionCode& ec) 3682 void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum form at, GC3Denum type, const void* pixels, ExceptionCode& ec)
3518 { 3683 {
3519 // FIXME: For now we ignore any errors returned 3684 // FIXME: For now we ignore any errors returned
3520 ec = 0; 3685 ec = 0;
3521 ASSERT(!isContextLost()); 3686 ASSERT(!isContextLost());
3522 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, lev el, format, width, height, 0, format, type)); 3687 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, lev el, format, width, height, 0, format, type));
3523 ASSERT(validateSize("texSubImage2D", xoffset, yoffset)); 3688 ASSERT(validateSize("texSubImage2D", xoffset, yoffset));
3524 ASSERT(validateSettableTexFormat("texSubImage2D", format)); 3689 ASSERT(validateSettableTexFormat("texSubImage2D", format));
3525 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); 3690 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true, We bGLSharedObject::Exclusive);
3526 if (!tex) { 3691 if (!tex) {
3527 ASSERT_NOT_REACHED(); 3692 ASSERT_NOT_REACHED();
3528 return; 3693 return;
3529 } 3694 }
3530 ASSERT((xoffset + width) >= 0); 3695 ASSERT((xoffset + width) >= 0);
3531 ASSERT((yoffset + height) >= 0); 3696 ASSERT((yoffset + height) >= 0);
3532 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); 3697 ASSERT(tex->getWidth(target, level) >= (xoffset + width));
3533 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); 3698 ASSERT(tex->getHeight(target, level) >= (yoffset + height));
3534 ASSERT(tex->getInternalFormat(target, level) == format); 3699 ASSERT(tex->getInternalFormat(target, level) == format);
3535 ASSERT(tex->getType(target, level) == type); 3700 ASSERT(tex->getType(target, level) == type);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3658 3823
3659 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e(), ec); 3824 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e(), ec);
3660 if (!image) 3825 if (!image)
3661 return; 3826 return;
3662 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); 3827 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
3663 } 3828 }
3664 3829
3665 void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3D float x, ExceptionCode& ec) 3830 void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3D float x, ExceptionCode& ec)
3666 { 3831 {
3667 UNUSED_PARAM(ec); 3832 UNUSED_PARAM(ec);
3668 if (isContextLost() || !location) 3833 if (!validateUniformParameters("uniform1f", location))
3669 return; 3834 return;
3670 3835
3671 if (location->program() != m_currentProgram) { 3836 if (location->program() != m_currentProgram) {
3672 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "lo cation not for current program"); 3837 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "lo cation not for current program");
3673 return; 3838 return;
3674 } 3839 }
3675 3840
3676 m_context->uniform1f(location->location(), x); 3841 m_context->uniform1f(location->location(), x);
3677 } 3842 }
3678 3843
3679 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec) 3844 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec)
3680 { 3845 {
3681 UNUSED_PARAM(ec); 3846 UNUSED_PARAM(ec);
3682 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1)) 3847 if (!validateUniformParameters("uniform1fv", location, v, 1))
3683 return; 3848 return;
3684 3849
3685 m_context->uniform1fv(location->location(), v->length(), v->data()); 3850 m_context->uniform1fv(location->location(), v->length(), v->data());
3686 } 3851 }
3687 3852
3688 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 3853 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3689 { 3854 {
3690 UNUSED_PARAM(ec); 3855 UNUSED_PARAM(ec);
3691 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1)) 3856 if (!validateUniformParameters("uniform1fv", location, v, size, 1))
3692 return; 3857 return;
3693 3858
3694 m_context->uniform1fv(location->location(), size, v); 3859 m_context->uniform1fv(location->location(), size, v);
3695 } 3860 }
3696 3861
3697 void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3D int x, ExceptionCode& ec) 3862 void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3D int x, ExceptionCode& ec)
3698 { 3863 {
3699 UNUSED_PARAM(ec); 3864 UNUSED_PARAM(ec);
3700 if (isContextLost() || !location) 3865 if (!validateUniformParameters("uniform1i", location))
3701 return; 3866 return;
3702 3867
3703 if (location->program() != m_currentProgram) { 3868 if (location->program() != m_currentProgram) {
3704 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "lo cation not for current program"); 3869 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "lo cation not for current program");
3705 return; 3870 return;
3706 } 3871 }
3707 3872
3873 m_currentProgram->conditionallyRecordTextureUnitsAssignedToSamplers(this, lo cation->location(), 1, &x);
3708 m_context->uniform1i(location->location(), x); 3874 m_context->uniform1i(location->location(), x);
3709 } 3875 }
3710 3876
3711 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec) 3877 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec)
3712 { 3878 {
3713 UNUSED_PARAM(ec); 3879 UNUSED_PARAM(ec);
3714 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1)) 3880 if (!validateUniformParameters("uniform1iv", location, v, 1))
3715 return; 3881 return;
3716 3882
3883 m_currentProgram->conditionallyRecordTextureUnitsAssignedToSamplers(this, lo cation->location(), v->length(), v->data());
3717 m_context->uniform1iv(location->location(), v->length(), v->data()); 3884 m_context->uniform1iv(location->location(), v->length(), v->data());
3718 } 3885 }
3719 3886
3720 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec) 3887 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec)
3721 { 3888 {
3722 UNUSED_PARAM(ec); 3889 UNUSED_PARAM(ec);
3723 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1)) 3890 if (!validateUniformParameters("uniform1iv", location, v, size, 1))
3724 return; 3891 return;
3725 3892
3893 m_currentProgram->conditionallyRecordTextureUnitsAssignedToSamplers(this, lo cation->location(), size, v);
3726 m_context->uniform1iv(location->location(), size, v); 3894 m_context->uniform1iv(location->location(), size, v);
3727 } 3895 }
3728 3896
3729 void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, ExceptionCode& ec) 3897 void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, ExceptionCode& ec)
3730 { 3898 {
3731 UNUSED_PARAM(ec); 3899 UNUSED_PARAM(ec);
3732 if (isContextLost() || !location) 3900 if (!validateUniformParameters("uniform2f", location))
3733 return; 3901 return;
3734 3902
3735 if (location->program() != m_currentProgram) {
3736 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2f", "lo cation not for current program");
3737 return;
3738 }
3739
3740 m_context->uniform2f(location->location(), x, y); 3903 m_context->uniform2f(location->location(), x, y);
3741 } 3904 }
3742 3905
3743 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec) 3906 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec)
3744 { 3907 {
3745 UNUSED_PARAM(ec); 3908 UNUSED_PARAM(ec);
3746 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2)) 3909 if (!validateUniformParameters("uniform2fv", location, v, 2))
3747 return; 3910 return;
3748 3911
3749 m_context->uniform2fv(location->location(), v->length() / 2, v->data()); 3912 m_context->uniform2fv(location->location(), v->length() / 2, v->data());
3750 } 3913 }
3751 3914
3752 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 3915 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3753 { 3916 {
3754 UNUSED_PARAM(ec); 3917 UNUSED_PARAM(ec);
3755 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2)) 3918 if (!validateUniformParameters("uniform2fv", location, v, size, 2))
3756 return; 3919 return;
3757 3920
3758 m_context->uniform2fv(location->location(), size / 2, v); 3921 m_context->uniform2fv(location->location(), size / 2, v);
3759 } 3922 }
3760 3923
3761 void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, ExceptionCode& ec) 3924 void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, ExceptionCode& ec)
3762 { 3925 {
3763 UNUSED_PARAM(ec); 3926 UNUSED_PARAM(ec);
3764 if (isContextLost() || !location) 3927 if (!validateUniformParameters("uniform2i", location))
3765 return; 3928 return;
3766 3929
3767 if (location->program() != m_currentProgram) {
3768 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2i", "lo cation not for current program");
3769 return;
3770 }
3771
3772 m_context->uniform2i(location->location(), x, y); 3930 m_context->uniform2i(location->location(), x, y);
3773 } 3931 }
3774 3932
3775 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec) 3933 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec)
3776 { 3934 {
3777 UNUSED_PARAM(ec); 3935 UNUSED_PARAM(ec);
3778 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2)) 3936 if (!validateUniformParameters("uniform2iv", location, v, 2))
3779 return; 3937 return;
3780 3938
3781 m_context->uniform2iv(location->location(), v->length() / 2, v->data()); 3939 m_context->uniform2iv(location->location(), v->length() / 2, v->data());
3782 } 3940 }
3783 3941
3784 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec) 3942 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec)
3785 { 3943 {
3786 UNUSED_PARAM(ec); 3944 UNUSED_PARAM(ec);
3787 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2)) 3945 if (!validateUniformParameters("uniform2iv", location, v, size, 2))
3788 return; 3946 return;
3789 3947
3790 m_context->uniform2iv(location->location(), size / 2, v); 3948 m_context->uniform2iv(location->location(), size / 2, v);
3791 } 3949 }
3792 3950
3793 void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, ExceptionCode& ec) 3951 void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, ExceptionCode& ec)
3794 { 3952 {
3795 UNUSED_PARAM(ec); 3953 UNUSED_PARAM(ec);
3796 if (isContextLost() || !location) 3954 if (!validateUniformParameters("uniform3f", location))
3797 return; 3955 return;
3798 3956
3799 if (location->program() != m_currentProgram) {
3800 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3f", "lo cation not for current program");
3801 return;
3802 }
3803
3804 m_context->uniform3f(location->location(), x, y, z); 3957 m_context->uniform3f(location->location(), x, y, z);
3805 } 3958 }
3806 3959
3807 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec) 3960 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec)
3808 { 3961 {
3809 UNUSED_PARAM(ec); 3962 UNUSED_PARAM(ec);
3810 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3)) 3963 if (!validateUniformParameters("uniform3fv", location, v, 3))
3811 return; 3964 return;
3812 3965
3813 m_context->uniform3fv(location->location(), v->length() / 3, v->data()); 3966 m_context->uniform3fv(location->location(), v->length() / 3, v->data());
3814 } 3967 }
3815 3968
3816 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 3969 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3817 { 3970 {
3818 UNUSED_PARAM(ec); 3971 UNUSED_PARAM(ec);
3819 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3)) 3972 if (!validateUniformParameters("uniform3fv", location, v, size, 3))
3820 return; 3973 return;
3821 3974
3822 m_context->uniform3fv(location->location(), size / 3, v); 3975 m_context->uniform3fv(location->location(), size / 3, v);
3823 } 3976 }
3824 3977
3825 void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, ExceptionCode& ec) 3978 void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, ExceptionCode& ec)
3826 { 3979 {
3827 UNUSED_PARAM(ec); 3980 UNUSED_PARAM(ec);
3828 if (isContextLost() || !location) 3981 if (!validateUniformParameters("uniform3i", location))
3829 return; 3982 return;
3830 3983
3831 if (location->program() != m_currentProgram) {
3832 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3i", "lo cation not for current program");
3833 return;
3834 }
3835
3836 m_context->uniform3i(location->location(), x, y, z); 3984 m_context->uniform3i(location->location(), x, y, z);
3837 } 3985 }
3838 3986
3839 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec) 3987 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec)
3840 { 3988 {
3841 UNUSED_PARAM(ec); 3989 UNUSED_PARAM(ec);
3842 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3)) 3990 if (!validateUniformParameters("uniform3iv", location, v, 3))
3843 return; 3991 return;
3844 3992
3845 m_context->uniform3iv(location->location(), v->length() / 3, v->data()); 3993 m_context->uniform3iv(location->location(), v->length() / 3, v->data());
3846 } 3994 }
3847 3995
3848 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec) 3996 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec)
3849 { 3997 {
3850 UNUSED_PARAM(ec); 3998 UNUSED_PARAM(ec);
3851 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3)) 3999 if (!validateUniformParameters("uniform3iv", location, v, size, 3))
3852 return; 4000 return;
3853 4001
3854 m_context->uniform3iv(location->location(), size / 3, v); 4002 m_context->uniform3iv(location->location(), size / 3, v);
3855 } 4003 }
3856 4004
3857 void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w, ExceptionCode& ec) 4005 void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w, ExceptionCode& ec)
3858 { 4006 {
3859 UNUSED_PARAM(ec); 4007 UNUSED_PARAM(ec);
3860 if (isContextLost() || !location) 4008 if (!validateUniformParameters("uniform4f", location))
3861 return; 4009 return;
3862 4010
3863 if (location->program() != m_currentProgram) {
3864 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4f", "lo cation not for current program");
3865 return;
3866 }
3867
3868 m_context->uniform4f(location->location(), x, y, z, w); 4011 m_context->uniform4f(location->location(), x, y, z, w);
3869 } 4012 }
3870 4013
3871 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec) 4014 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo at32Array* v, ExceptionCode& ec)
3872 { 4015 {
3873 UNUSED_PARAM(ec); 4016 UNUSED_PARAM(ec);
3874 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4)) 4017 if (!validateUniformParameters("uniform4fv", location, v, 4))
3875 return; 4018 return;
3876 4019
3877 m_context->uniform4fv(location->location(), v->length() / 4, v->data()); 4020 m_context->uniform4fv(location->location(), v->length() / 4, v->data());
3878 } 4021 }
3879 4022
3880 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 4023 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3881 { 4024 {
3882 UNUSED_PARAM(ec); 4025 UNUSED_PARAM(ec);
3883 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4)) 4026 if (!validateUniformParameters("uniform4fv", location, v, size, 4))
3884 return; 4027 return;
3885 4028
3886 m_context->uniform4fv(location->location(), size / 4, v); 4029 m_context->uniform4fv(location->location(), size / 4, v);
3887 } 4030 }
3888 4031
3889 void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, GC3Dint w, ExceptionCode& ec) 4032 void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, GC3Dint w, ExceptionCode& ec)
3890 { 4033 {
3891 UNUSED_PARAM(ec); 4034 UNUSED_PARAM(ec);
3892 if (isContextLost() || !location) 4035 if (!validateUniformParameters("uniform4i", location))
3893 return; 4036 return;
3894 4037
3895 if (location->program() != m_currentProgram) {
3896 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4i", "lo cation not for current program");
3897 return;
3898 }
3899
3900 m_context->uniform4i(location->location(), x, y, z, w); 4038 m_context->uniform4i(location->location(), x, y, z, w);
3901 } 4039 }
3902 4040
3903 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec) 4041 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int 32Array* v, ExceptionCode& ec)
3904 { 4042 {
3905 UNUSED_PARAM(ec); 4043 UNUSED_PARAM(ec);
3906 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4)) 4044 if (!validateUniformParameters("uniform4iv", location, v, 4))
3907 return; 4045 return;
3908 4046
3909 m_context->uniform4iv(location->location(), v->length() / 4, v->data()); 4047 m_context->uniform4iv(location->location(), v->length() / 4, v->data());
3910 } 4048 }
3911 4049
3912 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec) 4050 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size, ExceptionCode& ec)
3913 { 4051 {
3914 UNUSED_PARAM(ec); 4052 UNUSED_PARAM(ec);
3915 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, size, 4)) 4053 if (!validateUniformParameters("uniform4iv", location, v, size, 4))
3916 return; 4054 return;
3917 4055
3918 m_context->uniform4iv(location->location(), size / 4, v); 4056 m_context->uniform4iv(location->location(), size / 4, v);
3919 } 4057 }
3920 4058
3921 void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec) 4059 void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec)
3922 { 4060 {
3923 UNUSED_PARAM(ec); 4061 UNUSED_PARAM(ec);
3924 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, 4)) 4062 if (!validateUniformMatrixParameters("uniformMatrix2fv", location, transpose , v, 4))
3925 return; 4063 return;
3926 m_context->uniformMatrix2fv(location->location(), v->length() / 4, transpose , v->data()); 4064 m_context->uniformMatrix2fv(location->location(), v->length() / 4, transpose , v->data());
3927 } 4065 }
3928 4066
3929 void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 4067 void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3930 { 4068 {
3931 UNUSED_PARAM(ec); 4069 UNUSED_PARAM(ec);
3932 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, size, 4)) 4070 if (!validateUniformMatrixParameters("uniformMatrix2fv", location, transpose , v, size, 4))
3933 return; 4071 return;
3934 m_context->uniformMatrix2fv(location->location(), size / 4, transpose, v); 4072 m_context->uniformMatrix2fv(location->location(), size / 4, transpose, v);
3935 } 4073 }
3936 4074
3937 void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec) 4075 void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec)
3938 { 4076 {
3939 UNUSED_PARAM(ec); 4077 UNUSED_PARAM(ec);
3940 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, 9)) 4078 if (!validateUniformMatrixParameters("uniformMatrix3fv", location, transpose , v, 9))
3941 return; 4079 return;
3942 m_context->uniformMatrix3fv(location->location(), v->length() / 9, transpose , v->data()); 4080 m_context->uniformMatrix3fv(location->location(), v->length() / 9, transpose , v->data());
3943 } 4081 }
3944 4082
3945 void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 4083 void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3946 { 4084 {
3947 UNUSED_PARAM(ec); 4085 UNUSED_PARAM(ec);
3948 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, size, 9)) 4086 if (!validateUniformMatrixParameters("uniformMatrix3fv", location, transpose , v, size, 9))
3949 return; 4087 return;
3950 m_context->uniformMatrix3fv(location->location(), size / 9, transpose, v); 4088 m_context->uniformMatrix3fv(location->location(), size / 9, transpose, v);
3951 } 4089 }
3952 4090
3953 void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec) 4091 void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec)
3954 { 4092 {
3955 UNUSED_PARAM(ec); 4093 UNUSED_PARAM(ec);
3956 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, 16)) 4094 if (!validateUniformMatrixParameters("uniformMatrix4fv", location, transpose , v, 16))
3957 return; 4095 return;
3958 m_context->uniformMatrix4fv(location->location(), v->length() / 16, transpos e, v->data()); 4096 m_context->uniformMatrix4fv(location->location(), v->length() / 16, transpos e, v->data());
3959 } 4097 }
3960 4098
3961 void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) 4099 void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio n, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec)
3962 { 4100 {
3963 UNUSED_PARAM(ec); 4101 UNUSED_PARAM(ec);
3964 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, size, 16)) 4102 if (!validateUniformMatrixParameters("uniformMatrix4fv", location, transpose , v, size, 16))
3965 return; 4103 return;
3966 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); 4104 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v);
3967 } 4105 }
3968 4106
3969 void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec) 4107 void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec)
3970 { 4108 {
3971 UNUSED_PARAM(ec); 4109 UNUSED_PARAM(ec);
3972 bool deleted; 4110 bool deleted;
3973 if (!checkObjectToBeBound("useProgram", program, deleted)) 4111 bool boundSinceLastAcquire;
4112 if (!checkSharedObjectToBeBound("useProgram", program, deleted, boundSinceLa stAcquire))
3974 return; 4113 return;
3975 if (deleted) 4114 if (deleted)
3976 program = 0; 4115 program = 0;
3977 if (program && !program->getLinkStatus()) { 4116 if (program && !program->getLinkStatus(this)) {
3978 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p rogram not valid"); 4117 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p rogram not valid");
3979 return; 4118 return;
3980 } 4119 }
3981 if (m_currentProgram != program) { 4120 if (m_currentProgram != program) {
3982 if (m_currentProgram) 4121 if (m_currentProgram)
3983 m_currentProgram->onDetached(graphicsContext3D()); 4122 m_currentProgram->onDetached(graphicsContext3D());
3984 m_currentProgram = program; 4123 m_currentProgram = program;
3985 m_context->useProgram(objectOrZero(program)); 4124 m_context->useProgram(objectOrZero(program));
3986 if (program) 4125 if (program)
3987 program->onAttached(); 4126 program->onAttached();
3988 } 4127 }
4128 if (program && !boundSinceLastAcquire) {
4129 program->markAsBoundSinceLastAcquireForContext(this);
4130 }
3989 } 4131 }
3990 4132
3991 void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode & ec) 4133 void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode & ec)
3992 { 4134 {
3993 UNUSED_PARAM(ec); 4135 UNUSED_PARAM(ec);
3994 if (isContextLost() || !validateWebGLObject("validateProgram", program)) 4136 if (isContextLost() || !validateWebGLSharedObject("validateProgram", program , WebGLSharedObject::ReadOnly))
3995 return; 4137 return;
3996 m_context->validateProgram(objectOrZero(program)); 4138 m_context->validateProgram(objectOrZero(program));
3997 } 4139 }
3998 4140
3999 void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) 4141 void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0)
4000 { 4142 {
4001 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); 4143 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f);
4002 } 4144 }
4003 4145
4004 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v) 4146 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 if (!typeSize) { 4231 if (!typeSize) {
4090 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); 4232 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type");
4091 return; 4233 return;
4092 } 4234 }
4093 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { 4235 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) {
4094 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "stride or offset not valid for type"); 4236 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "stride or offset not valid for type");
4095 return; 4237 return;
4096 } 4238 }
4097 GC3Dsizei bytesPerElement = size * typeSize; 4239 GC3Dsizei bytesPerElement = size * typeSize;
4098 4240
4241 if (!isAcquiredForReading("vertexAttribPointer", m_boundArrayBuffer.get())) {
4242 return;
4243 }
4099 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); 4244 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer);
4100 m_context->vertexAttribPointer(index, size, type, normalized, stride, static _cast<GC3Dintptr>(offset)); 4245 m_context->vertexAttribPointer(index, size, type, normalized, stride, static _cast<GC3Dintptr>(offset));
4101 } 4246 }
4102 4247
4103 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di visor) 4248 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di visor)
4104 { 4249 {
4105 if (isContextLost()) 4250 if (isContextLost())
4106 return; 4251 return;
4107 4252
4108 if (index >= m_maxVertexAttribs) { 4253 if (index >= m_maxVertexAttribs) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
4326 case GraphicsContext3D::SCISSOR_BOX: 4471 case GraphicsContext3D::SCISSOR_BOX:
4327 case GraphicsContext3D::VIEWPORT: 4472 case GraphicsContext3D::VIEWPORT:
4328 length = 4; 4473 length = 4;
4329 break; 4474 break;
4330 default: 4475 default:
4331 notImplemented(); 4476 notImplemented();
4332 } 4477 }
4333 return WebGLGetInfo(Int32Array::create(value, length)); 4478 return WebGLGetInfo(Int32Array::create(value, length));
4334 } 4479 }
4335 4480
4336 void WebGLRenderingContext::handleTextureCompleteness(const char* functionName, bool prepareToDraw) 4481 bool WebGLRenderingContext::handleTextureCompleteness(const char* functionName, bool prepareToDraw, bool* texturesReplaced)
4337 { 4482 {
4483 if (texturesReplaced) {
4484 *texturesReplaced = false;
4485 }
4338 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 4486 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
4339 bool resetActiveUnit = false; 4487 bool resetActiveUnit = false;
4340 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE xtensionFlag>((m_oesTextureFloatLinear ? WebGLTexture::TextureFloatLinearExtensi onEnabled : 0) 4488 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE xtensionFlag>((m_oesTextureFloatLinear ? WebGLTexture::TextureFloatLinearExtensi onEnabled : 0)
4341 | (m_oesTextureHalfFloatLinear ? WebGLTexture::TextureHalfFloatLinearExt ensionEnabled : 0)); 4489 | (m_oesTextureHalfFloatLinear ? WebGLTexture::TextureHalfFloatLinearExt ensionEnabled : 0));
4342 for (unsigned ii = 0; ii < m_textureUnits.size(); ++ii) { 4490
4343 if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m _texture2DBinding->needToUseBlackTexture(flag)) 4491 const WebGLProgram::SamplerTextureUnitMap& samplerMap = m_currentProgram->sa mplerLocationTextureUnitMap();
4344 || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUni ts[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) { 4492 for (WebGLProgram::SamplerTextureUnitMap::const_iterator it = samplerMap.beg in(); it != samplerMap.end(); ++it) {
4345 if (ii != m_activeTextureUnit) { 4493 GC3Dint unit = it->value.unit;
4346 m_context->activeTexture(ii); 4494 GC3Denum type = it->value.type;
4347 resetActiveUnit = true; 4495 WebGLTexture* texture;
4348 } else if (resetActiveUnit) { 4496 WebGLTexture* blackTexture;
4349 m_context->activeTexture(ii); 4497 GC3Denum target;
4350 resetActiveUnit = false; 4498 switch (it->value.type) {
4499 case GraphicsContext3D::SAMPLER_2D:
4500 target = GraphicsContext3D::TEXTURE_2D;
4501 texture = m_textureUnits[unit].m_texture2DBinding.get();
4502 blackTexture = m_blackTexture2D.get();
4503 break;
4504 case GraphicsContext3D::SAMPLER_CUBE:
4505 target = GraphicsContext3D::TEXTURE_CUBE_MAP;
4506 texture = m_textureUnits[unit].m_textureCubeMapBinding.get();
4507 blackTexture = m_blackTextureCubeMap.get();
4508 break;
4509 default:
4510 notImplemented();
4511 }
4512
4513 if (!texture) {
4514 continue;
4515 }
4516
4517 if (prepareToDraw && !isAcquiredForReading(functionName, texture)) {
4518 // We don't restore any state here but instead expect this function will be called
4519 // again with prepareToDraw false which will restore any state we ch anged while
4520 // prepareToDraw was true.
4521 return false;
4522 }
4523
4524 if (texture->needToUseBlackTexture(flag)) {
4525 if (texturesReplaced) {
4526 *texturesReplaced = true;
4351 } 4527 }
4352 WebGLTexture* tex2D; 4528 m_context->activeTexture(GraphicsContext3D::TEXTURE0 + unit);
4353 WebGLTexture* texCubeMap; 4529 resetActiveUnit = true;
4530 WebGLTexture* tex;
4354 if (prepareToDraw) { 4531 if (prepareToDraw) {
4355 String msg(String("texture bound to texture unit ") + String::nu mber(ii) 4532 String msg(String("texture bound to texture unit ") + String::nu mber(unit)
4356 + " is not renderable. It maybe non-power-of-2 and have inco mpatible texture filtering or is not 'texture complete'." 4533 + " is not renderable. It maybe non-power-of-2 and have inco mpatible texture filtering or is not 'texture complete'."
4357 + " Or the texture is Float or Half Float type with linear f iltering while OES_float_linear or OES_half_float_linear extension is not enable d."); 4534 + " Or the texture is Float or Half Float type with linear f iltering while OES_float_linear or OES_half_float_linear extension is not enable d.");
4358 printGLWarningToConsole(functionName, msg.utf8().data()); 4535 printGLWarningToConsole(functionName, msg.utf8().data());
4359 tex2D = m_blackTexture2D.get(); 4536 tex = blackTexture;
4360 texCubeMap = m_blackTextureCubeMap.get();
4361 } else { 4537 } else {
4362 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); 4538 tex = texture;
4363 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
4364 } 4539 }
4365 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te xture2DBinding->needToUseBlackTexture(flag)) 4540 m_context->bindTexture(target, objectOrZero(tex));
4366 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZe ro(tex2D));
4367 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii] .m_textureCubeMapBinding->needToUseBlackTexture(flag))
4368 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, obje ctOrZero(texCubeMap));
4369 } 4541 }
4370 } 4542 }
4371 if (resetActiveUnit) 4543 if (resetActiveUnit)
4372 m_context->activeTexture(m_activeTextureUnit); 4544 m_context->activeTexture(GraphicsContext3D::TEXTURE0 + m_activeTextureUn it);
4545
4546 return true;
4373 } 4547 }
4374 4548
4375 void WebGLRenderingContext::createFallbackBlackTextures1x1() 4549 void WebGLRenderingContext::createFallbackBlackTextures1x1()
4376 { 4550 {
4377 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 4551 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
4378 unsigned char black[] = {0, 0, 0, 255}; 4552 unsigned char black[] = {0, 0, 0, 255};
4379 m_blackTexture2D = createTexture(); 4553 m_blackTexture2D = createTexture();
4380 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D->obje ct()); 4554 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D->obje ct());
4381 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::R GBA, 1, 1, 4555 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::R GBA, 1, 1,
4382 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4556 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4422 return m_drawingBuffer->size().width(); 4596 return m_drawingBuffer->size().width();
4423 } 4597 }
4424 4598
4425 int WebGLRenderingContext::getBoundFramebufferHeight() 4599 int WebGLRenderingContext::getBoundFramebufferHeight()
4426 { 4600 {
4427 if (m_framebufferBinding && m_framebufferBinding->object()) 4601 if (m_framebufferBinding && m_framebufferBinding->object())
4428 return m_framebufferBinding->getColorBufferHeight(); 4602 return m_framebufferBinding->getColorBufferHeight();
4429 return m_drawingBuffer->size().height(); 4603 return m_drawingBuffer->size().height();
4430 } 4604 }
4431 4605
4432 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function Name, GC3Denum target, bool useSixEnumsForCubeMap) 4606 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function Name, GC3Denum target, bool useSixEnumsForCubeMap, WebGLSharedObject::AcquireMod e mode)
4433 { 4607 {
4434 WebGLTexture* tex = 0; 4608 WebGLTexture* tex = 0;
4435 switch (target) { 4609 switch (target) {
4436 case GraphicsContext3D::TEXTURE_2D: 4610 case GraphicsContext3D::TEXTURE_2D:
4437 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); 4611 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get();
4438 break; 4612 break;
4439 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: 4613 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
4440 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: 4614 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
4441 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: 4615 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
4442 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: 4616 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
(...skipping 11 matching lines...) Expand all
4454 return 0; 4628 return 0;
4455 } 4629 }
4456 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); 4630 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();
4457 break; 4631 break;
4458 default: 4632 default:
4459 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture target"); 4633 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture target");
4460 return 0; 4634 return 0;
4461 } 4635 }
4462 if (!tex) 4636 if (!tex)
4463 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o texture"); 4637 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o texture");
4638 switch (mode) {
4639 case WebGLSharedObject::ReadOnly:
4640 if (!isAcquiredForReading(functionName, tex)) {
4641 return 0;
4642 }
4643 break;
4644 case WebGLSharedObject::Exclusive:
4645 if (!isAcquiredForModification(functionName, tex)) {
4646 return 0;
4647 }
4648 break;
4649 default:
4650 notImplemented();
4651 break;
4652 }
4464 return tex; 4653 return tex;
4465 } 4654 }
4466 4655
4467 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con st String& string) 4656 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con st String& string)
4468 { 4657 {
4469 const unsigned maxWebGLLocationLength = 256; 4658 const unsigned maxWebGLLocationLength = 256;
4470 if (string.length() > maxWebGLLocationLength) { 4659 if (string.length() > maxWebGLLocationLength) {
4471 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat ion length > 256"); 4660 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat ion length > 256");
4472 return false; 4661 return false;
4473 } 4662 }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
5032 case GraphicsContext3D::SAMPLE_COVERAGE: 5221 case GraphicsContext3D::SAMPLE_COVERAGE:
5033 case GraphicsContext3D::SCISSOR_TEST: 5222 case GraphicsContext3D::SCISSOR_TEST:
5034 case GraphicsContext3D::STENCIL_TEST: 5223 case GraphicsContext3D::STENCIL_TEST:
5035 return true; 5224 return true;
5036 default: 5225 default:
5037 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d capability"); 5226 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d capability");
5038 return false; 5227 return false;
5039 } 5228 }
5040 } 5229 }
5041 5230
5042 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize ) 5231 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location)
5232 {
5233 if (isContextLost() || !location) {
5234 return false;
5235 }
5236
5237 if (location->program() != m_currentProgram) {
5238 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "l ocation is not from current program");
5239 return false;
5240 }
5241
5242 if (!isAcquiredForModification(functionName, m_currentProgram.get())) {
5243 return false;
5244 }
5245
5246 return true;
5247 }
5248
5249 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize)
5043 { 5250 {
5044 if (!v) { 5251 if (!v) {
5045 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5252 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray");
5046 return false; 5253 return false;
5047 } 5254 }
5048 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); 5255 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize);
5049 } 5256 }
5050 5257
5051 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize) 5258 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize )
5052 { 5259 {
5053 if (!v) { 5260 if (!v) {
5054 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5261 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray");
5055 return false; 5262 return false;
5056 } 5263 }
5057 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); 5264 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize);
5058 } 5265 }
5059 5266
5060 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei require dMinSize) 5267 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei require dMinSize)
5061 { 5268 {
5062 return validateUniformMatrixParameters(functionName, location, false, v, siz e, requiredMinSize); 5269 return validateUniformMatrixParameters(functionName, location, false, v, siz e, requiredMinSize);
5063 } 5270 }
5064 5271
5065 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize) 5272 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize)
5066 { 5273 {
5067 if (!v) { 5274 if (!v) {
5068 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5275 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray");
5069 return false; 5276 return false;
5070 } 5277 }
5071 return validateUniformMatrixParameters(functionName, location, transpose, v- >data(), v->length(), requiredMinSize); 5278 return validateUniformMatrixParameters(functionName, location, transpose, v- >data(), v->length(), requiredMinSize);
5072 } 5279 }
5073 5280
5074 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3D sizei size, GC3Dsizei requiredMinSize) 5281 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3D sizei size, GC3Dsizei requiredMinSize)
5075 { 5282 {
5076 if (!location) 5283 if (isContextLost() || !location)
5077 return false; 5284 return false;
5078 if (location->program() != m_currentProgram) { 5285 if (location->program() != m_currentProgram) {
5079 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "l ocation is not from current program"); 5286 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "l ocation is not from current program");
5080 return false; 5287 return false;
5081 } 5288 }
5289 if (!isAcquiredForModification(functionName, m_currentProgram.get())) {
5290 return false;
5291 }
5292
5082 if (!v) { 5293 if (!v) {
5083 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5294 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray");
5084 return false; 5295 return false;
5085 } 5296 }
5086 if (transpose) { 5297 if (transpose) {
5087 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans pose not FALSE"); 5298 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans pose not FALSE");
5088 return false; 5299 return false;
5089 } 5300 }
5090 if (size < requiredMinSize || (size % requiredMinSize)) { 5301 if (size < requiredMinSize || (size % requiredMinSize)) {
5091 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); 5302 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size");
5092 return false; 5303 return false;
5093 } 5304 }
5094 return true; 5305 return true;
5095 } 5306 }
5096 5307
5097 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun ctionName, GC3Denum target, GC3Denum usage) 5308 WebGLBuffer* WebGLRenderingContext::getBufferForTarget(const char* functionName, GC3Denum target)
5098 { 5309 {
5099 WebGLBuffer* buffer = 0; 5310 WebGLBuffer* buffer = 0;
5100 switch (target) { 5311 switch (target) {
5101 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER: 5312 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER:
5102 buffer = m_boundVertexArrayObject->getElementArrayBuffer().get(); 5313 buffer = m_boundVertexArrayObject->getElementArrayBuffer().get();
5103 break; 5314 break;
5104 case GraphicsContext3D::ARRAY_BUFFER: 5315 case GraphicsContext3D::ARRAY_BUFFER:
5105 buffer = m_boundArrayBuffer.get(); 5316 buffer = m_boundArrayBuffer.get();
5106 break; 5317 break;
5107 default: 5318 default:
5108 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); 5319 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target");
5109 return 0; 5320 return 0;
5110 } 5321 }
5111 if (!buffer) { 5322 if (!buffer) {
5112 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o buffer"); 5323 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o buffer");
5113 return 0; 5324 return 0;
5114 } 5325 }
5326 return buffer;
5327 }
5328
5329 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun ctionName, GC3Denum target, GC3Denum usage)
5330 {
5331 WebGLBuffer* buffer = getBufferForTarget(functionName, target);
5332 if (!buffer) {
5333 return 0;
5334 }
5335
5336 if (!isAcquiredForModification(functionName, buffer))
5337 return 0;
5115 switch (usage) { 5338 switch (usage) {
5116 case GraphicsContext3D::STREAM_DRAW: 5339 case GraphicsContext3D::STREAM_DRAW:
5117 case GraphicsContext3D::STATIC_DRAW: 5340 case GraphicsContext3D::STATIC_DRAW:
5118 case GraphicsContext3D::DYNAMIC_DRAW: 5341 case GraphicsContext3D::DYNAMIC_DRAW:
5119 return buffer; 5342 return buffer;
5120 } 5343 }
5121 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us age"); 5344 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us age");
5122 return 0; 5345 return 0;
5123 } 5346 }
5124 5347
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5177 if (first < 0 || count < 0) { 5400 if (first < 0 || count < 0) {
5178 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "first or count < 0"); 5401 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "first or count < 0");
5179 return false; 5402 return false;
5180 } 5403 }
5181 5404
5182 if (!count) { 5405 if (!count) {
5183 markContextChanged(); 5406 markContextChanged();
5184 return false; 5407 return false;
5185 } 5408 }
5186 5409
5187 if (!validateRenderingState()) { 5410 if (!validateRenderingState(functionName)) {
5188 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a ttribs not setup correctly");
5189 return false; 5411 return false;
5190 } 5412 }
5191 5413
5192 const char* reason = "framebuffer incomplete"; 5414 const char* reason = "framebuffer incomplete";
5193 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 5415 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare dObject::Exclusive, &reason)) {
5194 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); 5416 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason);
5195 return false; 5417 return false;
5196 } 5418 }
5197 5419
5198 return true; 5420 return true;
5199 } 5421 }
5200 5422
5201 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De num mode, GC3Dsizei count, GC3Denum type, long long offset) 5423 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De num mode, GC3Dsizei count, GC3Denum type, long long offset)
5202 { 5424 {
5203 if (isContextLost() || !validateDrawMode(functionName, mode)) 5425 if (isContextLost() || !validateDrawMode(functionName, mode))
(...skipping 24 matching lines...) Expand all
5228 if (!count) { 5450 if (!count) {
5229 markContextChanged(); 5451 markContextChanged();
5230 return false; 5452 return false;
5231 } 5453 }
5232 5454
5233 if (!m_boundVertexArrayObject->getElementArrayBuffer()) { 5455 if (!m_boundVertexArrayObject->getElementArrayBuffer()) {
5234 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o ELEMENT_ARRAY_BUFFER bound"); 5456 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o ELEMENT_ARRAY_BUFFER bound");
5235 return false; 5457 return false;
5236 } 5458 }
5237 5459
5238 if (!validateRenderingState()) { 5460 if (!isAcquiredForReading(functionName, m_boundVertexArrayObject->getElement ArrayBuffer().get())) {
5239 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a ttribs not setup correctly"); 5461 return false;
5462 }
5463
5464 if (!validateRenderingState(functionName)) {
5240 return false; 5465 return false;
5241 } 5466 }
5242 5467
5243 const char* reason = "framebuffer incomplete"; 5468 const char* reason = "framebuffer incomplete";
5244 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 5469 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare dObject::Exclusive, &reason)) {
5245 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); 5470 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason);
5246 return false; 5471 return false;
5247 } 5472 }
5248 5473
5249 return true; 5474 return true;
5250 } 5475 }
5251 5476
5252 // Helper function to validate draw*Instanced calls 5477 // Helper function to validate draw*Instanced calls
5253 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D sizei primcount) 5478 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D sizei primcount)
5254 { 5479 {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
5579 5804
5580 void WebGLRenderingContext::multisamplingChanged(bool enabled) 5805 void WebGLRenderingContext::multisamplingChanged(bool enabled)
5581 { 5806 {
5582 if (m_multisamplingAllowed != enabled) { 5807 if (m_multisamplingAllowed != enabled) {
5583 m_multisamplingAllowed = enabled; 5808 m_multisamplingAllowed = enabled;
5584 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ; 5809 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ;
5585 } 5810 }
5586 } 5811 }
5587 5812
5588 } // namespace WebCore 5813 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | Source/core/html/canvas/WebGLShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698