OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 25 matching lines...) Expand all Loading... |
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 Loading... |
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 Loading... |
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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; | 1003 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; |
996 m_context->activeTexture(texture); | 1004 m_context->activeTexture(texture); |
997 | 1005 |
998 m_drawingBuffer->setActiveTextureUnit(texture); | 1006 m_drawingBuffer->setActiveTextureUnit(texture); |
999 | 1007 |
1000 } | 1008 } |
1001 | 1009 |
1002 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha
der, ExceptionCode& ec) | 1010 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha
der, ExceptionCode& ec) |
1003 { | 1011 { |
1004 UNUSED_PARAM(ec); | 1012 UNUSED_PARAM(ec); |
1005 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) | 1013 bool boundSinceLastAcquire; |
| 1014 bool deleted; |
| 1015 if (isContextLost() |
| 1016 || !validateWebGLSharedObject("attachShader", program, WebGLSharedObject
::Exclusive) |
| 1017 || !checkSharedObjectToBeBound("attachShader", shader, deleted, boundSin
ceLastAcquire)) { |
1006 return; | 1018 return; |
| 1019 } |
| 1020 if (deleted) { |
| 1021 shader = 0; |
| 1022 } |
1007 if (!program->attachShader(shader)) { | 1023 if (!program->attachShader(shader)) { |
1008 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader",
"shader attachment already has shader"); | 1024 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader",
"shader attachment already has shader"); |
1009 return; | 1025 return; |
1010 } | 1026 } |
1011 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); | 1027 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); |
1012 shader->onAttached(); | 1028 if (shader) { |
| 1029 shader->onAttached(); |
| 1030 if (!boundSinceLastAcquire) { |
| 1031 shader->markAsBoundSinceLastAcquireForContext(this); |
| 1032 } |
| 1033 } |
1013 } | 1034 } |
1014 | 1035 |
1015 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i
ndex, const String& name, ExceptionCode& ec) | 1036 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i
ndex, const String& name, ExceptionCode& ec) |
1016 { | 1037 { |
1017 UNUSED_PARAM(ec); | 1038 UNUSED_PARAM(ec); |
1018 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 1039 if (isContextLost() || !validateWebGLSharedObject("bindAttribLocation", prog
ram, WebGLSharedObject::Exclusive)) |
1019 return; | 1040 return; |
1020 if (!validateLocationLength("bindAttribLocation", name)) | 1041 if (!validateLocationLength("bindAttribLocation", name)) |
1021 return; | 1042 return; |
1022 if (!validateString("bindAttribLocation", name)) | 1043 if (!validateString("bindAttribLocation", name)) |
1023 return; | 1044 return; |
1024 if (isPrefixReserved(name)) { | 1045 if (isPrefixReserved(name)) { |
1025 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat
ion", "reserved prefix"); | 1046 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat
ion", "reserved prefix"); |
1026 return; | 1047 return; |
1027 } | 1048 } |
1028 if (index >= m_maxVertexAttribs) { | 1049 if (index >= m_maxVertexAttribs) { |
1029 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation"
, "index out of range"); | 1050 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation"
, "index out of range"); |
1030 return; | 1051 return; |
1031 } | 1052 } |
1032 m_context->bindAttribLocation(objectOrZero(program), index, name); | 1053 m_context->bindAttribLocation(objectOrZero(program), index, name); |
1033 } | 1054 } |
1034 | 1055 |
1035 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL
Object* object, bool& deleted) | 1056 bool WebGLRenderingContext::checkContextObjectToBeBound(const char* functionName
, WebGLContextObject* object, bool& deleted) |
1036 { | 1057 { |
1037 deleted = false; | 1058 deleted = false; |
1038 if (isContextLost()) | 1059 if (isContextLost()) |
1039 return false; | 1060 return false; |
1040 if (object) { | 1061 if (object) { |
1041 if (!object->validate(contextGroup(), this)) { | 1062 if (!object->validate(contextGroup(), this)) { |
1042 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName
, "object not from this context"); | 1063 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName
, "object not from this share group"); |
1043 return false; | 1064 return false; |
1044 } | 1065 } |
1045 deleted = !object->object(); | 1066 deleted = !object->object(); |
| 1067 } |
| 1068 return true; |
| 1069 } |
| 1070 |
| 1071 bool WebGLRenderingContext::checkSharedObjectToBeBound(const char* functionName,
WebGLSharedObject* object, bool& deleted, bool& boundSinceLastAcquire) |
| 1072 { |
| 1073 deleted = false; |
| 1074 if (isContextLost()) |
| 1075 return false; |
| 1076 if (object) { |
| 1077 if (!object->validate(functionName, this, WebGLSharedObject::ReadOnly, f
alse, &boundSinceLastAcquire)) { |
| 1078 return false; |
| 1079 } |
| 1080 deleted = !object->object(); |
1046 } | 1081 } |
1047 return true; | 1082 return true; |
1048 } | 1083 } |
1049 | 1084 |
1050 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer, Exc
eptionCode& ec) | 1085 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer, Exc
eptionCode& ec) |
1051 { | 1086 { |
1052 UNUSED_PARAM(ec); | 1087 UNUSED_PARAM(ec); |
1053 bool deleted; | 1088 bool deleted; |
1054 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) | 1089 bool boundSinceLastAcquire; |
| 1090 if (!checkSharedObjectToBeBound("bindBuffer", buffer, deleted, boundSinceLas
tAcquire)) |
1055 return; | 1091 return; |
1056 if (deleted) | 1092 if (deleted) |
1057 buffer = 0; | 1093 buffer = 0; |
1058 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { | 1094 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { |
1059 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b
uffers can not be used with multiple targets"); | 1095 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b
uffers can not be used with multiple targets"); |
1060 return; | 1096 return; |
1061 } | 1097 } |
1062 if (target == GraphicsContext3D::ARRAY_BUFFER) | 1098 if (target == GraphicsContext3D::ARRAY_BUFFER) |
1063 m_boundArrayBuffer = buffer; | 1099 m_boundArrayBuffer = buffer; |
1064 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) | 1100 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) |
1065 m_boundVertexArrayObject->setElementArrayBuffer(buffer); | 1101 m_boundVertexArrayObject->setElementArrayBuffer(buffer); |
1066 else { | 1102 else { |
1067 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali
d target"); | 1103 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali
d target"); |
1068 return; | 1104 return; |
1069 } | 1105 } |
1070 | 1106 |
1071 m_context->bindBuffer(target, objectOrZero(buffer)); | 1107 m_context->bindBuffer(target, objectOrZero(buffer)); |
1072 if (buffer) | 1108 if (buffer) { |
1073 buffer->setTarget(target); | 1109 buffer->setTarget(target); |
| 1110 if (!boundSinceLastAcquire) { |
| 1111 buffer->markAsBoundSinceLastAcquireForContext(this); |
| 1112 } |
| 1113 } |
1074 } | 1114 } |
1075 | 1115 |
1076 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b
uffer, ExceptionCode& ec) | 1116 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b
uffer, ExceptionCode& ec) |
1077 { | 1117 { |
1078 UNUSED_PARAM(ec); | 1118 UNUSED_PARAM(ec); |
1079 bool deleted; | 1119 bool deleted; |
1080 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1120 if (!checkContextObjectToBeBound("bindFramebuffer", buffer, deleted)) |
1081 return; | 1121 return; |
1082 if (deleted) | 1122 if (deleted) |
1083 buffer = 0; | 1123 buffer = 0; |
1084 if (target != GraphicsContext3D::FRAMEBUFFER) { | 1124 if (target != GraphicsContext3D::FRAMEBUFFER) { |
1085 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i
nvalid target"); | 1125 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i
nvalid target"); |
1086 return; | 1126 return; |
1087 } | 1127 } |
1088 m_framebufferBinding = buffer; | 1128 m_framebufferBinding = buffer; |
1089 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); | 1129 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); |
1090 if (!m_framebufferBinding) { | 1130 if (!m_framebufferBinding) { |
1091 // Instead of binding fb 0, bind the drawing buffer. | 1131 // Instead of binding fb 0, bind the drawing buffer. |
1092 m_drawingBuffer->bind(); | 1132 m_drawingBuffer->bind(); |
1093 } else | 1133 } else |
1094 m_context->bindFramebuffer(target, objectOrZero(buffer)); | 1134 m_context->bindFramebuffer(target, objectOrZero(buffer)); |
1095 if (buffer) | 1135 if (buffer) |
1096 buffer->setHasEverBeenBound(); | 1136 buffer->setHasEverBeenBound(); |
1097 applyStencilTest(); | 1137 applyStencilTest(); |
1098 } | 1138 } |
1099 | 1139 |
1100 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*
renderBuffer, ExceptionCode& ec) | 1140 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*
renderBuffer, ExceptionCode& ec) |
1101 { | 1141 { |
1102 UNUSED_PARAM(ec); | 1142 UNUSED_PARAM(ec); |
1103 bool deleted; | 1143 bool deleted; |
1104 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1144 bool boundSinceLastAcquire; |
| 1145 if (!checkSharedObjectToBeBound("bindRenderbuffer", renderBuffer, deleted, b
oundSinceLastAcquire)) |
1105 return; | 1146 return; |
1106 if (deleted) | 1147 if (deleted) |
1107 renderBuffer = 0; | 1148 renderBuffer = 0; |
1108 if (target != GraphicsContext3D::RENDERBUFFER) { | 1149 if (target != GraphicsContext3D::RENDERBUFFER) { |
1109 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", "
invalid target"); | 1150 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", "
invalid target"); |
1110 return; | 1151 return; |
1111 } | 1152 } |
1112 m_renderbufferBinding = renderBuffer; | 1153 m_renderbufferBinding = renderBuffer; |
1113 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1154 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
1114 if (renderBuffer) | 1155 if (renderBuffer) { |
1115 renderBuffer->setHasEverBeenBound(); | 1156 renderBuffer->setHasEverBeenBound(); |
| 1157 if (!boundSinceLastAcquire) { |
| 1158 renderBuffer->markAsBoundSinceLastAcquireForContext(this); |
| 1159 } |
| 1160 } |
1116 } | 1161 } |
1117 | 1162 |
1118 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture,
ExceptionCode& ec) | 1163 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture,
ExceptionCode& ec) |
1119 { | 1164 { |
1120 UNUSED_PARAM(ec); | 1165 UNUSED_PARAM(ec); |
1121 bool deleted; | 1166 bool deleted; |
1122 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1167 bool boundSinceLastAcquire; |
| 1168 if (!checkSharedObjectToBeBound("bindTexture", texture, deleted, boundSinceL
astAcquire)) |
1123 return; | 1169 return; |
1124 if (deleted) | 1170 if (deleted) |
1125 texture = 0; | 1171 texture = 0; |
1126 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1172 if (texture && texture->getTarget() && texture->getTarget() != target) { |
1127 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", "
textures can not be used with multiple targets"); | 1173 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", "
textures can not be used with multiple targets"); |
1128 return; | 1174 return; |
1129 } | 1175 } |
1130 GC3Dint maxLevel = 0; | 1176 GC3Dint maxLevel = 0; |
1131 if (target == GraphicsContext3D::TEXTURE_2D) { | 1177 if (target == GraphicsContext3D::TEXTURE_2D) { |
1132 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1178 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
1133 maxLevel = m_maxTextureLevel; | 1179 maxLevel = m_maxTextureLevel; |
1134 | 1180 |
1135 if (!m_activeTextureUnit) | 1181 if (!m_activeTextureUnit) |
1136 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); | 1182 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); |
1137 | 1183 |
1138 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { | 1184 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { |
1139 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1185 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
1140 maxLevel = m_maxCubeMapTextureLevel; | 1186 maxLevel = m_maxCubeMapTextureLevel; |
1141 } else { | 1187 } else { |
1142 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "inval
id target"); | 1188 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "inval
id target"); |
1143 return; | 1189 return; |
1144 } | 1190 } |
1145 m_context->bindTexture(target, objectOrZero(texture)); | 1191 m_context->bindTexture(target, objectOrZero(texture)); |
1146 if (texture) | 1192 if (texture) { |
1147 texture->setTarget(target, maxLevel); | 1193 texture->setTarget(target, maxLevel); |
| 1194 if (!boundSinceLastAcquire) { |
| 1195 texture->markAsBoundSinceLastAcquireForContext(this); |
| 1196 } |
| 1197 } |
1148 | 1198 |
1149 // Note: previously we used to automatically set the TEXTURE_WRAP_R | 1199 // Note: previously we used to automatically set the TEXTURE_WRAP_R |
1150 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL | 1200 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL |
1151 // ES 2.0 doesn't expose this flag (a bug in the specification) and | 1201 // ES 2.0 doesn't expose this flag (a bug in the specification) and |
1152 // otherwise the application has no control over the seams in this | 1202 // otherwise the application has no control over the seams in this |
1153 // dimension. However, it appears that supporting this properly on all | 1203 // dimension. However, it appears that supporting this properly on all |
1154 // platforms is fairly involved (will require a HashMap from texture ID | 1204 // platforms is fairly involved (will require a HashMap from texture ID |
1155 // in all ports), and we have not had any complaints, so the logic has | 1205 // in all ports), and we have not had any complaints, so the logic has |
1156 // been removed. | 1206 // been removed. |
1157 | 1207 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 if (!data) | 1328 if (!data) |
1279 return; | 1329 return; |
1280 | 1330 |
1281 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte
Length(), data->baseAddress()); | 1331 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte
Length(), data->baseAddress()); |
1282 } | 1332 } |
1283 | 1333 |
1284 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) | 1334 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) |
1285 { | 1335 { |
1286 if (isContextLost()) | 1336 if (isContextLost()) |
1287 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; | 1337 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; |
1288 if (target != GraphicsContext3D::FRAMEBUFFER) { | 1338 switch (target) { |
| 1339 case GraphicsContext3D::FRAMEBUFFER: |
| 1340 case Extensions3D::READ_FRAMEBUFFER: |
| 1341 case Extensions3D::DRAW_FRAMEBUFFER: |
| 1342 break; |
| 1343 default: |
1289 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat
us", "invalid target"); | 1344 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat
us", "invalid target"); |
1290 return 0; | 1345 return 0; |
1291 } | 1346 } |
1292 if (!m_framebufferBinding || !m_framebufferBinding->object()) | 1347 if (!m_framebufferBinding || !m_framebufferBinding->object()) |
1293 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; | 1348 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; |
1294 const char* reason = "framebuffer incomplete"; | 1349 const char* reason = "framebuffer incomplete"; |
1295 GC3Denum result = m_framebufferBinding->checkStatus(&reason); | 1350 WebGLSharedObject::AcquireMode neededAccessMode = (target == Extensions3D::R
EAD_FRAMEBUFFER) ? WebGLSharedObject::ReadOnly : WebGLSharedObject::Exclusive; |
| 1351 GC3Denum result = m_framebufferBinding->checkStatus(this, neededAccessMode,
&reason); |
1296 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { | 1352 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { |
1297 printGLWarningToConsole("checkFramebufferStatus", reason); | 1353 printGLWarningToConsole("checkFramebufferStatus", reason); |
1298 return result; | 1354 return result; |
1299 } | 1355 } |
1300 result = m_context->checkFramebufferStatus(target); | 1356 result = m_context->checkFramebufferStatus(target); |
1301 return result; | 1357 return result; |
1302 } | 1358 } |
1303 | 1359 |
1304 void WebGLRenderingContext::clear(GC3Dbitfield mask) | 1360 void WebGLRenderingContext::clear(GC3Dbitfield mask) |
1305 { | 1361 { |
1306 if (isContextLost()) | 1362 if (isContextLost()) |
1307 return; | 1363 return; |
1308 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_
BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { | 1364 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_
BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { |
1309 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma
sk"); | 1365 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma
sk"); |
1310 return; | 1366 return; |
1311 } | 1367 } |
1312 const char* reason = "framebuffer incomplete"; | 1368 const char* reason = "framebuffer incomplete"; |
1313 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 1369 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare
dObject::Exclusive, &reason)) { |
1314 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle
ar", reason); | 1370 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle
ar", reason); |
1315 return; | 1371 return; |
1316 } | 1372 } |
1317 if (!clearIfComposited(mask)) | 1373 if (!clearIfComposited(mask)) |
1318 m_context->clear(mask); | 1374 m_context->clear(mask); |
1319 markContextChanged(); | 1375 markContextChanged(); |
1320 } | 1376 } |
1321 | 1377 |
1322 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC
3Dfloat a) | 1378 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC
3Dfloat a) |
1323 { | 1379 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 m_colorMask[0] = red; | 1417 m_colorMask[0] = red; |
1362 m_colorMask[1] = green; | 1418 m_colorMask[1] = green; |
1363 m_colorMask[2] = blue; | 1419 m_colorMask[2] = blue; |
1364 m_colorMask[3] = alpha; | 1420 m_colorMask[3] = alpha; |
1365 m_context->colorMask(red, green, blue, alpha); | 1421 m_context->colorMask(red, green, blue, alpha); |
1366 } | 1422 } |
1367 | 1423 |
1368 void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
) | 1424 void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
) |
1369 { | 1425 { |
1370 UNUSED_PARAM(ec); | 1426 UNUSED_PARAM(ec); |
1371 if (isContextLost() || !validateWebGLObject("compileShader", shader)) | 1427 if (isContextLost() || !validateWebGLSharedObject("compileShader", shader, W
ebGLSharedObject::Exclusive)) |
1372 return; | 1428 return; |
1373 m_context->compileShader(objectOrZero(shader)); | 1429 m_context->compileShader(objectOrZero(shader)); |
1374 } | 1430 } |
1375 | 1431 |
1376 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level,
GC3Denum internalformat, GC3Dsizei width, | 1432 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level,
GC3Denum internalformat, GC3Dsizei width, |
1377 GC3Dsizei height, GC3Dint borde
r, ArrayBufferView* data) | 1433 GC3Dsizei height, GC3Dint borde
r, ArrayBufferView* data) |
1378 { | 1434 { |
1379 if (isContextLost()) | 1435 if (isContextLost()) |
1380 return; | 1436 return; |
1381 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) | 1437 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) |
1382 return; | 1438 return; |
1383 | 1439 |
1384 if (!validateCompressedTexFormat(internalformat)) { | 1440 if (!validateCompressedTexFormat(internalformat)) { |
1385 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D
", "invalid internalformat"); | 1441 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D
", "invalid internalformat"); |
1386 return; | 1442 return; |
1387 } | 1443 } |
1388 if (border) { | 1444 if (border) { |
1389 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2
D", "border not 0"); | 1445 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2
D", "border not 0"); |
1390 return; | 1446 return; |
1391 } | 1447 } |
1392 if (!validateCompressedTexDimensions("compressedTexImage2D", level, width, h
eight, internalformat)) | 1448 if (!validateCompressedTexDimensions("compressedTexImage2D", level, width, h
eight, internalformat)) |
1393 return; | 1449 return; |
1394 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in
ternalformat, data)) | 1450 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in
ternalformat, data)) |
1395 return; | 1451 return; |
1396 | 1452 |
1397 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t
rue); | 1453 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t
rue, WebGLSharedObject::Exclusive); |
1398 if (!tex) | 1454 if (!tex) |
1399 return; | 1455 return; |
1400 if (!isGLES2NPOTStrict()) { | 1456 if (!isGLES2NPOTStrict()) { |
1401 if (level && WebGLTexture::isNPOT(width, height)) { | 1457 if (level && WebGLTexture::isNPOT(width, height)) { |
1402 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm
age2D", "level > 0 not power of 2"); | 1458 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm
age2D", "level > 0 not power of 2"); |
1403 return; | 1459 return; |
1404 } | 1460 } |
1405 } | 1461 } |
1406 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid
th, height, | 1462 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid
th, height, |
1407 border, data->byteLength(), data->
baseAddress()); | 1463 border, data->byteLength(), data->
baseAddress()); |
1408 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont
ext3D::UNSIGNED_BYTE); | 1464 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont
ext3D::UNSIGNED_BYTE); |
1409 } | 1465 } |
1410 | 1466 |
1411 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev
el, GC3Dint xoffset, GC3Dint yoffset, | 1467 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev
el, GC3Dint xoffset, GC3Dint yoffset, |
1412 GC3Dsizei width, GC3Dsizei h
eight, GC3Denum format, ArrayBufferView* data) | 1468 GC3Dsizei width, GC3Dsizei h
eight, GC3Denum format, ArrayBufferView* data) |
1413 { | 1469 { |
1414 if (isContextLost()) | 1470 if (isContextLost()) |
1415 return; | 1471 return; |
1416 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) | 1472 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) |
1417 return; | 1473 return; |
1418 if (!validateCompressedTexFormat(format)) { | 1474 if (!validateCompressedTexFormat(format)) { |
1419 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag
e2D", "invalid format"); | 1475 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag
e2D", "invalid format"); |
1420 return; | 1476 return; |
1421 } | 1477 } |
1422 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height,
format, data)) | 1478 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height,
format, data)) |
1423 return; | 1479 return; |
1424 | 1480 |
1425 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target
, true); | 1481 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target
, true, WebGLSharedObject::Exclusive); |
1426 if (!tex) | 1482 if (!tex) |
1427 return; | 1483 return; |
1428 | 1484 |
1429 if (format != tex->getInternalFormat(target, level)) { | 1485 if (format != tex->getInternalFormat(target, level)) { |
1430 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu
bImage2D", "format does not match texture format"); | 1486 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu
bImage2D", "format does not match texture format"); |
1431 return; | 1487 return; |
1432 } | 1488 } |
1433 | 1489 |
1434 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l
evel, xoffset, yoffset, width, height, format, tex)) | 1490 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l
evel, xoffset, yoffset, width, height, format, tex)) |
1435 return; | 1491 return; |
(...skipping 12 matching lines...) Expand all Loading... |
1448 } | 1504 } |
1449 | 1505 |
1450 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De
num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3
Dint border) | 1506 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De
num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3
Dint border) |
1451 { | 1507 { |
1452 if (isContextLost()) | 1508 if (isContextLost()) |
1453 return; | 1509 return; |
1454 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l
evel, internalformat, width, height, border, internalformat, GraphicsContext3D::
UNSIGNED_BYTE)) | 1510 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l
evel, internalformat, width, height, border, internalformat, GraphicsContext3D::
UNSIGNED_BYTE)) |
1455 return; | 1511 return; |
1456 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) | 1512 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) |
1457 return; | 1513 return; |
1458 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); | 1514 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true, W
ebGLSharedObject::Exclusive); |
1459 if (!tex) | 1515 if (!tex) |
1460 return; | 1516 return; |
1461 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound
FramebufferColorFormat())) { | 1517 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound
FramebufferColorFormat())) { |
1462 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D"
, "framebuffer is incompatible format"); | 1518 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D"
, "framebuffer is incompatible format"); |
1463 return; | 1519 return; |
1464 } | 1520 } |
1465 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1521 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
1466 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "l
evel > 0 not power of 2"); | 1522 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "l
evel > 0 not power of 2"); |
1467 return; | 1523 return; |
1468 } | 1524 } |
1469 const char* reason = "framebuffer incomplete"; | 1525 const char* reason = "framebuffer incomplete"; |
1470 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 1526 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare
dObject::ReadOnly, &reason)) { |
1471 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop
yTexImage2D", reason); | 1527 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop
yTexImage2D", reason); |
1472 return; | 1528 return; |
1473 } | 1529 } |
1474 clearIfComposited(); | 1530 clearIfComposited(); |
1475 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1531 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
1476 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); | 1532 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); |
1477 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. | 1533 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. |
1478 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont
ext3D::UNSIGNED_BYTE); | 1534 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont
ext3D::UNSIGNED_BYTE); |
1479 } | 1535 } |
1480 | 1536 |
1481 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC
3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei
height) | 1537 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC
3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei
height) |
1482 { | 1538 { |
1483 if (isContextLost()) | 1539 if (isContextLost()) |
1484 return; | 1540 return; |
1485 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1541 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
1486 return; | 1542 return; |
1487 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true
); | 1543 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true
, WebGLSharedObject::Exclusive); |
1488 if (!tex) | 1544 if (!tex) |
1489 return; | 1545 return; |
1490 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c
opyTexSubImage2D", width, height)) | 1546 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c
opyTexSubImage2D", width, height)) |
1491 return; | 1547 return; |
1492 // Before checking if it is in the range, check if overflow happens first. | 1548 // Before checking if it is in the range, check if overflow happens first. |
1493 if (xoffset + width < 0 || yoffset + height < 0) { | 1549 if (xoffset + width < 0 || yoffset + height < 0) { |
1494 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D",
"bad dimensions"); | 1550 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D",
"bad dimensions"); |
1495 return; | 1551 return; |
1496 } | 1552 } |
1497 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex
->getHeight(target, level)) { | 1553 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex
->getHeight(target, level)) { |
1498 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D",
"rectangle out of range"); | 1554 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D",
"rectangle out of range"); |
1499 return; | 1555 return; |
1500 } | 1556 } |
1501 GC3Denum internalformat = tex->getInternalFormat(target, level); | 1557 GC3Denum internalformat = tex->getInternalFormat(target, level); |
1502 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) | 1558 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) |
1503 return; | 1559 return; |
1504 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound
FramebufferColorFormat())) { | 1560 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBound
FramebufferColorFormat())) { |
1505 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage
2D", "framebuffer is incompatible format"); | 1561 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage
2D", "framebuffer is incompatible format"); |
1506 return; | 1562 return; |
1507 } | 1563 } |
1508 const char* reason = "framebuffer incomplete"; | 1564 const char* reason = "framebuffer incomplete"; |
1509 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 1565 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare
dObject::ReadOnly, &reason)) { |
1510 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop
yTexSubImage2D", reason); | 1566 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop
yTexSubImage2D", reason); |
1511 return; | 1567 return; |
1512 } | 1568 } |
1513 clearIfComposited(); | 1569 clearIfComposited(); |
1514 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1570 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
1515 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); | 1571 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); |
1516 } | 1572 } |
1517 | 1573 |
1518 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() | 1574 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() |
1519 { | 1575 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 return o; | 1643 return o; |
1588 } | 1644 } |
1589 | 1645 |
1590 void WebGLRenderingContext::cullFace(GC3Denum mode) | 1646 void WebGLRenderingContext::cullFace(GC3Denum mode) |
1591 { | 1647 { |
1592 if (isContextLost()) | 1648 if (isContextLost()) |
1593 return; | 1649 return; |
1594 m_context->cullFace(mode); | 1650 m_context->cullFace(mode); |
1595 } | 1651 } |
1596 | 1652 |
1597 bool WebGLRenderingContext::deleteObject(WebGLObject* object) | 1653 bool WebGLRenderingContext::deleteContextObject(const char* functionName, WebGLC
ontextObject* object) |
1598 { | 1654 { |
1599 if (isContextLost() || !object) | 1655 if (isContextLost() || !object) |
1600 return false; | 1656 return false; |
1601 if (!object->validate(contextGroup(), this)) { | 1657 if (!object->validate(contextGroup(), this)) { |
1602 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "objec
t does not belong to this context"); | 1658 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o
bject does not belong to this share group"); |
| 1659 return false; |
| 1660 } |
| 1661 if (object->object()) { |
| 1662 // We need to pass in context here because we want |
| 1663 // things in this context unbound. |
| 1664 object->deleteObject(graphicsContext3D()); |
| 1665 } |
| 1666 return true; |
| 1667 } |
| 1668 |
| 1669 bool WebGLRenderingContext::deleteSharedObject(const char* functionName, WebGLSh
aredObject* object) |
| 1670 { |
| 1671 if (isContextLost() || !object) |
| 1672 return false; |
| 1673 if (!object->validate(functionName, this, WebGLSharedObject::Exclusive, true
, 0)) { |
1603 return false; | 1674 return false; |
1604 } | 1675 } |
1605 if (object->object()) | 1676 if (object->object()) |
1606 // We need to pass in context here because we want | 1677 // We need to pass in context here because we want |
1607 // things in this context unbound. | 1678 // things in this context unbound. |
1608 object->deleteObject(graphicsContext3D()); | 1679 object->deleteObject(graphicsContext3D()); |
1609 return true; | 1680 return true; |
1610 } | 1681 } |
1611 | 1682 |
1612 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) | 1683 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) |
1613 { | 1684 { |
1614 if (!deleteObject(buffer)) | 1685 if (!deleteSharedObject("deleteBuffer", buffer)) |
1615 return; | 1686 return; |
1616 if (m_boundArrayBuffer == buffer) | 1687 if (m_boundArrayBuffer == buffer) |
1617 m_boundArrayBuffer = 0; | 1688 m_boundArrayBuffer = 0; |
1618 | 1689 |
1619 m_boundVertexArrayObject->unbindBuffer(buffer); | 1690 m_boundVertexArrayObject->unbindBuffer(buffer); |
1620 } | 1691 } |
1621 | 1692 |
1622 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) | 1693 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
1623 { | 1694 { |
1624 if (!deleteObject(framebuffer)) | 1695 if (!deleteContextObject("deleteFramebuffer", framebuffer)) |
1625 return; | 1696 return; |
1626 if (framebuffer == m_framebufferBinding) { | 1697 if (framebuffer == m_framebufferBinding) { |
1627 m_framebufferBinding = 0; | 1698 m_framebufferBinding = 0; |
1628 m_drawingBuffer->setFramebufferBinding(0); | 1699 m_drawingBuffer->setFramebufferBinding(0); |
1629 // Have to call bindFramebuffer here to bind back to internal fbo. | 1700 // Have to call bindFramebuffer here to bind back to internal fbo. |
1630 m_drawingBuffer->bind(); | 1701 m_drawingBuffer->bind(); |
1631 } | 1702 } |
1632 } | 1703 } |
1633 | 1704 |
1634 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) | 1705 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) |
1635 { | 1706 { |
1636 deleteObject(program); | 1707 deleteSharedObject("deleteProgram", program); |
1637 // We don't reset m_currentProgram to 0 here because the deletion of the | 1708 // We don't reset m_currentProgram to 0 here because the deletion of the |
1638 // current program is delayed. | 1709 // current program is delayed. |
1639 } | 1710 } |
1640 | 1711 |
1641 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) | 1712 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) |
1642 { | 1713 { |
1643 if (!deleteObject(renderbuffer)) | 1714 if (!deleteSharedObject("deleteRenderbuffer", renderbuffer)) |
1644 return; | 1715 return; |
1645 if (renderbuffer == m_renderbufferBinding) | 1716 if (renderbuffer == m_renderbufferBinding) |
1646 m_renderbufferBinding = 0; | 1717 m_renderbufferBinding = 0; |
1647 if (m_framebufferBinding) | 1718 if (m_framebufferBinding) |
1648 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer)
; | 1719 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer)
; |
1649 } | 1720 } |
1650 | 1721 |
1651 void WebGLRenderingContext::deleteShader(WebGLShader* shader) | 1722 void WebGLRenderingContext::deleteShader(WebGLShader* shader) |
1652 { | 1723 { |
1653 deleteObject(shader); | 1724 deleteSharedObject("deleteShader", shader); |
1654 } | 1725 } |
1655 | 1726 |
1656 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) | 1727 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) |
1657 { | 1728 { |
1658 if (!deleteObject(texture)) | 1729 if (!deleteSharedObject("deleteTexture", texture)) |
1659 return; | 1730 return; |
1660 for (size_t i = 0; i < m_textureUnits.size(); ++i) { | 1731 for (size_t i = 0; i < m_textureUnits.size(); ++i) { |
1661 if (texture == m_textureUnits[i].m_texture2DBinding) | 1732 if (texture == m_textureUnits[i].m_texture2DBinding) |
1662 m_textureUnits[i].m_texture2DBinding = 0; | 1733 m_textureUnits[i].m_texture2DBinding = 0; |
1663 if (texture == m_textureUnits[i].m_textureCubeMapBinding) | 1734 if (texture == m_textureUnits[i].m_textureCubeMapBinding) |
1664 m_textureUnits[i].m_textureCubeMapBinding = 0; | 1735 m_textureUnits[i].m_textureCubeMapBinding = 0; |
1665 } | 1736 } |
1666 if (m_framebufferBinding) | 1737 if (m_framebufferBinding) |
1667 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); | 1738 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); |
1668 } | 1739 } |
(...skipping 20 matching lines...) Expand all Loading... |
1689 if (zNear > zFar) { | 1760 if (zNear > zFar) { |
1690 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z
Near > zFar"); | 1761 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z
Near > zFar"); |
1691 return; | 1762 return; |
1692 } | 1763 } |
1693 m_context->depthRange(zNear, zFar); | 1764 m_context->depthRange(zNear, zFar); |
1694 } | 1765 } |
1695 | 1766 |
1696 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
der, ExceptionCode& ec) | 1767 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
der, ExceptionCode& ec) |
1697 { | 1768 { |
1698 UNUSED_PARAM(ec); | 1769 UNUSED_PARAM(ec); |
1699 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) | 1770 bool boundSinceLastAcquire; |
| 1771 bool deleted; |
| 1772 // 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 |
| 1773 // there would be no way to detach a shader in context other than the one |
| 1774 // that attached it. |
| 1775 if (isContextLost() |
| 1776 || !validateWebGLSharedObject("detachShader", program, WebGLSharedObject
::Exclusive) |
| 1777 || !checkSharedObjectToBeBound("detachShader", shader, deleted, boundSin
ceLastAcquire)) { |
1700 return; | 1778 return; |
| 1779 } |
| 1780 if (deleted) { |
| 1781 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader",
"shader deleted"); |
| 1782 return; |
| 1783 } |
1701 if (!program->detachShader(shader)) { | 1784 if (!program->detachShader(shader)) { |
1702 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader",
"shader not attached"); | 1785 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader",
"shader not attached"); |
1703 return; | 1786 return; |
1704 } | 1787 } |
1705 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); | 1788 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); |
1706 shader->onDetached(graphicsContext3D()); | 1789 shader->onDetached(graphicsContext3D()); |
1707 } | 1790 } |
1708 | 1791 |
1709 void WebGLRenderingContext::disable(GC3Denum cap) | 1792 void WebGLRenderingContext::disable(GC3Denum cap) |
1710 { | 1793 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 for (unsigned i = 0; i < m_maxVertexAttribs; ++i) { | 1829 for (unsigned i = 0; i < m_maxVertexAttribs; ++i) { |
1747 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte
xArrayObject->getVertexAttribState(i); | 1830 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte
xArrayObject->getVertexAttribState(i); |
1748 if (state.enabled | 1831 if (state.enabled |
1749 && (!state.bufferBinding || !state.bufferBinding->object())) | 1832 && (!state.bufferBinding || !state.bufferBinding->object())) |
1750 return false; | 1833 return false; |
1751 } | 1834 } |
1752 | 1835 |
1753 return true; | 1836 return true; |
1754 } | 1837 } |
1755 | 1838 |
1756 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO
bject* object) | 1839 bool WebGLRenderingContext::isAcquiredForModification(const char* functionName,
WebGLSharedObject* object) |
| 1840 { |
| 1841 return validateWebGLSharedObject(functionName, object, WebGLSharedObject::Ex
clusive); |
| 1842 } |
| 1843 |
| 1844 bool WebGLRenderingContext::isAcquiredForReading(const char* functionName, WebGL
SharedObject* object) |
| 1845 { |
| 1846 return validateWebGLSharedObject(functionName, object, WebGLSharedObject::Re
adOnly); |
| 1847 } |
| 1848 |
| 1849 bool WebGLRenderingContext::validateWebGLSharedObject(const char* functionName,
WebGLSharedObject* object, WebGLSharedObject::AcquireMode acquireMode) |
1757 { | 1850 { |
1758 if (!object || !object->object()) { | 1851 if (!object || !object->object()) { |
1759 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob
ject or object deleted"); | 1852 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob
ject or object deleted"); |
1760 return false; | 1853 return false; |
1761 } | 1854 } |
1762 if (!object->validate(contextGroup(), this)) { | 1855 if (!object->validate(functionName, this, acquireMode, true, 0)) { |
1763 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o
bject does not belong to this context"); | |
1764 return false; | 1856 return false; |
1765 } | 1857 } |
1766 return true; | 1858 return true; |
1767 } | 1859 } |
1768 | 1860 |
| 1861 long WebGLRenderingContext::acquireSharedResource(WebGLSharedObject* object, Web
GLSharedObject::AcquireMode desiredMode, PassRefPtr<WebGLAcquireSharedResourceCa
llback> callback, ExceptionCode& ec) |
| 1862 { |
| 1863 UNUSED_PARAM(ec); |
| 1864 if (!object) { |
| 1865 return 0; |
| 1866 } |
| 1867 |
| 1868 long id; |
| 1869 if (!object->addAcquireRequest(this, desiredMode, callback, id)) { |
| 1870 return 0; |
| 1871 } |
| 1872 |
| 1873 return id; |
| 1874 } |
| 1875 |
| 1876 void WebGLRenderingContext::releaseSharedResource(WebGLSharedObject* object, Exc
eptionCode& ec) |
| 1877 { |
| 1878 UNUSED_PARAM(ec); |
| 1879 |
| 1880 if (!object) { |
| 1881 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "releaseSharedRe
source", "no resource"); |
| 1882 return; |
| 1883 } |
| 1884 |
| 1885 if (!object->release(this)) { |
| 1886 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "releaseSharedRe
source", "resource not acquired"); |
| 1887 } |
| 1888 } |
| 1889 |
| 1890 void WebGLRenderingContext::cancelAcquireSharedResource(long id) |
| 1891 { |
| 1892 m_contextGroup->cancelAcquireSharedResource(this, id); |
| 1893 } |
| 1894 |
1769 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c
ount, ExceptionCode& ec) | 1895 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c
ount, ExceptionCode& ec) |
1770 { | 1896 { |
1771 UNUSED_PARAM(ec); | 1897 UNUSED_PARAM(ec); |
1772 | 1898 |
1773 if (!validateDrawArrays("drawArrays", mode, first, count)) | 1899 if (!validateDrawArrays("drawArrays", mode, first, count)) |
1774 return; | 1900 return; |
1775 | 1901 |
1776 clearIfComposited(); | 1902 clearIfComposited(); |
1777 | 1903 |
1778 handleTextureCompleteness("drawArrays", true); | 1904 handleTextureCompleteness("drawArrays", true); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 | 2002 |
1877 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at
tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode&
ec) | 2003 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at
tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode&
ec) |
1878 { | 2004 { |
1879 UNUSED_PARAM(ec); | 2005 UNUSED_PARAM(ec); |
1880 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) | 2006 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) |
1881 return; | 2007 return; |
1882 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { | 2008 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { |
1883 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf
fer", "invalid target"); | 2009 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf
fer", "invalid target"); |
1884 return; | 2010 return; |
1885 } | 2011 } |
1886 if (buffer && !buffer->validate(contextGroup(), this)) { | 2012 bool hasBeenBoundSinceLastAcquire; |
1887 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend
erbuffer", "no buffer or buffer not from this context"); | 2013 if (buffer && !buffer->validate("framebufferRenderbuffer", this, WebGLShared
Object::Exclusive, false, &hasBeenBoundSinceLastAcquire)) { |
1888 return; | 2014 return; |
1889 } | 2015 } |
1890 // Don't allow the default framebuffer to be mutated; all current | 2016 // Don't allow the default framebuffer to be mutated; all current |
1891 // implementations use an FBO internally in place of the default | 2017 // implementations use an FBO internally in place of the default |
1892 // FBO. | 2018 // FBO. |
1893 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2019 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
1894 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend
erbuffer", "no framebuffer bound"); | 2020 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend
erbuffer", "no framebuffer bound"); |
1895 return; | 2021 return; |
1896 } | 2022 } |
1897 Platform3DObject bufferObject = objectOrZero(buffer); | 2023 Platform3DObject bufferObject = objectOrZero(buffer); |
| 2024 if (buffer && !hasBeenBoundSinceLastAcquire) { |
| 2025 buffer->markAsBoundSinceLastAcquireForContext(this); |
| 2026 } |
1898 switch (attachment) { | 2027 switch (attachment) { |
1899 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: | 2028 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: |
1900 if (isDepthStencilSupported() || !buffer) { | 2029 if (isDepthStencilSupported() || !buffer) { |
1901 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_
ATTACHMENT, renderbuffertarget, bufferObject); | 2030 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_
ATTACHMENT, renderbuffertarget, bufferObject); |
1902 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI
L_ATTACHMENT, renderbuffertarget, bufferObject); | 2031 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI
L_ATTACHMENT, renderbuffertarget, bufferObject); |
1903 } else { | 2032 } else { |
1904 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); | 2033 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); |
1905 if (!emulatedStencilBuffer) { | 2034 if (!emulatedStencilBuffer) { |
1906 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "framebuffer
Renderbuffer", "out of memory"); | 2035 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "framebuffer
Renderbuffer", "out of memory"); |
1907 return; | 2036 return; |
(...skipping 11 matching lines...) Expand all Loading... |
1919 | 2048 |
1920 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac
hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode&
ec) | 2049 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac
hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode&
ec) |
1921 { | 2050 { |
1922 UNUSED_PARAM(ec); | 2051 UNUSED_PARAM(ec); |
1923 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) | 2052 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) |
1924 return; | 2053 return; |
1925 if (level) { | 2054 if (level) { |
1926 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2
D", "level not 0"); | 2055 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2
D", "level not 0"); |
1927 return; | 2056 return; |
1928 } | 2057 } |
1929 if (texture && !texture->validate(contextGroup(), this)) { | 2058 bool hasBeenBoundSinceLastAcquire; |
1930 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText
ure2D", "no texture or texture not from this context"); | 2059 if (texture && !texture->validate("framebufferTexture2D", this, WebGLSharedO
bject::Exclusive, false, &hasBeenBoundSinceLastAcquire)) { |
1931 return; | 2060 return; |
1932 } | 2061 } |
1933 // Don't allow the default framebuffer to be mutated; all current | 2062 // Don't allow the default framebuffer to be mutated; all current |
1934 // implementations use an FBO internally in place of the default | 2063 // implementations use an FBO internally in place of the default |
1935 // FBO. | 2064 // FBO. |
1936 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2065 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
1937 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText
ure2D", "no framebuffer bound"); | 2066 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText
ure2D", "no framebuffer bound"); |
1938 return; | 2067 return; |
1939 } | 2068 } |
1940 Platform3DObject textureObject = objectOrZero(texture); | 2069 Platform3DObject textureObject = objectOrZero(texture); |
| 2070 if (texture && !hasBeenBoundSinceLastAcquire) { |
| 2071 texture->markAsBoundSinceLastAcquireForContext(this); |
| 2072 } |
1941 switch (attachment) { | 2073 switch (attachment) { |
1942 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: | 2074 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: |
1943 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM
ENT, textarget, textureObject, level); | 2075 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM
ENT, textarget, textureObject, level); |
1944 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC
HMENT, textarget, textureObject, level); | 2076 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC
HMENT, textarget, textureObject, level); |
1945 break; | 2077 break; |
1946 case GraphicsContext3D::DEPTH_ATTACHMENT: | 2078 case GraphicsContext3D::DEPTH_ATTACHMENT: |
1947 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 2079 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); |
1948 break; | 2080 break; |
1949 case GraphicsContext3D::STENCIL_ATTACHMENT: | 2081 case GraphicsContext3D::STENCIL_ATTACHMENT: |
1950 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 2082 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); |
1951 break; | 2083 break; |
1952 default: | 2084 default: |
1953 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 2085 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); |
1954 } | 2086 } |
1955 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); | 2087 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); |
1956 applyStencilTest(); | 2088 applyStencilTest(); |
1957 } | 2089 } |
1958 | 2090 |
1959 void WebGLRenderingContext::frontFace(GC3Denum mode) | 2091 void WebGLRenderingContext::frontFace(GC3Denum mode) |
1960 { | 2092 { |
1961 if (isContextLost()) | 2093 if (isContextLost()) |
1962 return; | 2094 return; |
1963 m_context->frontFace(mode); | 2095 m_context->frontFace(mode); |
1964 } | 2096 } |
1965 | 2097 |
1966 void WebGLRenderingContext::generateMipmap(GC3Denum target) | 2098 void WebGLRenderingContext::generateMipmap(GC3Denum target) |
1967 { | 2099 { |
1968 if (isContextLost()) | 2100 if (isContextLost()) |
1969 return; | 2101 return; |
1970 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); | 2102 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false,
WebGLSharedObject::Exclusive); |
1971 if (!tex) | 2103 if (!tex) |
1972 return; | 2104 return; |
1973 if (!tex->canGenerateMipmaps()) { | 2105 if (!tex->canGenerateMipmaps()) { |
1974 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap"
, "level 0 not power of 2 or not all the same size"); | 2106 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap"
, "level 0 not power of 2 or not all the same size"); |
1975 return; | 2107 return; |
1976 } | 2108 } |
1977 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) | 2109 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) |
1978 return; | 2110 return; |
1979 | 2111 |
1980 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR | 2112 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR |
1981 // on Mac. Remove the hack once this driver bug is fixed. | 2113 // on Mac. Remove the hack once this driver bug is fixed. |
1982 #if OS(DARWIN) | 2114 #if OS(DARWIN) |
1983 bool needToResetMinFilter = false; | 2115 bool needToResetMinFilter = false; |
1984 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { | 2116 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { |
1985 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER,
GraphicsContext3D::NEAREST_MIPMAP_LINEAR); | 2117 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER,
GraphicsContext3D::NEAREST_MIPMAP_LINEAR); |
1986 needToResetMinFilter = true; | 2118 needToResetMinFilter = true; |
1987 } | 2119 } |
1988 #endif | 2120 #endif |
1989 m_context->generateMipmap(target); | 2121 m_context->generateMipmap(target); |
1990 #if OS(DARWIN) | 2122 #if OS(DARWIN) |
1991 if (needToResetMinFilter) | 2123 if (needToResetMinFilter) |
1992 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER,
tex->getMinFilter()); | 2124 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER,
tex->getMinFilter()); |
1993 #endif | 2125 #endif |
1994 tex->generateMipmapLevelInfo(); | 2126 tex->generateMipmapLevelInfo(); |
1995 } | 2127 } |
1996 | 2128 |
1997 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
program, GC3Duint index, ExceptionCode& ec) | 2129 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
program, GC3Duint index, ExceptionCode& ec) |
1998 { | 2130 { |
1999 UNUSED_PARAM(ec); | 2131 UNUSED_PARAM(ec); |
2000 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2132 if (isContextLost() || !validateWebGLSharedObject("getActiveAttrib", program
, WebGLSharedObject::ReadOnly)) |
2001 return 0; | 2133 return 0; |
2002 ActiveInfo info; | 2134 ActiveInfo info; |
2003 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) | 2135 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) |
2004 return 0; | 2136 return 0; |
2005 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2137 return WebGLActiveInfo::create(info.name, info.type, info.size); |
2006 } | 2138 } |
2007 | 2139 |
2008 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram
* program, GC3Duint index, ExceptionCode& ec) | 2140 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram
* program, GC3Duint index, ExceptionCode& ec) |
2009 { | 2141 { |
2010 UNUSED_PARAM(ec); | 2142 UNUSED_PARAM(ec); |
2011 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 2143 if (isContextLost() || !validateWebGLSharedObject("getActiveUniform", progra
m, WebGLSharedObject::ReadOnly)) |
2012 return 0; | 2144 return 0; |
2013 ActiveInfo info; | 2145 ActiveInfo info; |
2014 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) | 2146 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) |
2015 return 0; | 2147 return 0; |
2016 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2148 return WebGLActiveInfo::create(info.name, info.type, info.size); |
2017 } | 2149 } |
2018 | 2150 |
2019 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref
Ptr<WebGLShader> >& shaderObjects, ExceptionCode& ec) | 2151 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref
Ptr<WebGLShader> >& shaderObjects, ExceptionCode& ec) |
2020 { | 2152 { |
2021 UNUSED_PARAM(ec); | 2153 UNUSED_PARAM(ec); |
2022 shaderObjects.clear(); | 2154 shaderObjects.clear(); |
2023 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 2155 if (isContextLost() || !validateWebGLSharedObject("getAttachedShaders", prog
ram, WebGLSharedObject::ReadOnly)) |
2024 return false; | 2156 return false; |
2025 | 2157 |
2026 const GC3Denum shaderType[] = { | 2158 const GC3Denum shaderType[] = { |
2027 GraphicsContext3D::VERTEX_SHADER, | 2159 GraphicsContext3D::VERTEX_SHADER, |
2028 GraphicsContext3D::FRAGMENT_SHADER | 2160 GraphicsContext3D::FRAGMENT_SHADER |
2029 }; | 2161 }; |
2030 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { | 2162 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { |
2031 WebGLShader* shader = program->getAttachedShader(shaderType[i]); | 2163 WebGLShader* shader = program->getAttachedShader(shaderType[i]); |
2032 if (shader) | 2164 if (shader) |
2033 shaderObjects.append(shader); | 2165 shaderObjects.append(shader); |
2034 } | 2166 } |
2035 return true; | 2167 return true; |
2036 } | 2168 } |
2037 | 2169 |
2038 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St
ring& name) | 2170 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St
ring& name) |
2039 { | 2171 { |
2040 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) | 2172 if (isContextLost() || !validateWebGLSharedObject("getAttribLocation", progr
am, WebGLSharedObject::ReadOnly)) |
2041 return -1; | 2173 return -1; |
2042 if (!validateLocationLength("getAttribLocation", name)) | 2174 if (!validateLocationLength("getAttribLocation", name)) |
2043 return -1; | 2175 return -1; |
2044 if (!validateString("getAttribLocation", name)) | 2176 if (!validateString("getAttribLocation", name)) |
2045 return -1; | 2177 return -1; |
2046 if (isPrefixReserved(name)) | 2178 if (isPrefixReserved(name)) |
2047 return -1; | 2179 return -1; |
2048 if (!program->getLinkStatus()) { | 2180 if (!program->getLinkStatus(this)) { |
2049 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati
on", "program not linked"); | 2181 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati
on", "program not linked"); |
2050 return 0; | 2182 return 0; |
2051 } | 2183 } |
2052 return m_context->getAttribLocation(objectOrZero(program), name); | 2184 return m_context->getAttribLocation(objectOrZero(program), name); |
2053 } | 2185 } |
2054 | 2186 |
2055 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum
pname, ExceptionCode& ec) | 2187 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum
pname, ExceptionCode& ec) |
2056 { | 2188 { |
2057 UNUSED_PARAM(ec); | 2189 UNUSED_PARAM(ec); |
2058 if (isContextLost()) | 2190 if (isContextLost()) |
2059 return WebGLGetInfo(); | 2191 return WebGLGetInfo(); |
2060 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D
::ELEMENT_ARRAY_BUFFER) { | 2192 |
2061 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter",
"invalid target"); | 2193 WebGLBuffer* buffer = getBufferForTarget("getBufferParameter", target); |
| 2194 if (!buffer) { |
2062 return WebGLGetInfo(); | 2195 return WebGLGetInfo(); |
2063 } | 2196 } |
2064 | 2197 |
2065 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B
UFFER_USAGE) { | 2198 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B
UFFER_USAGE) { |
2066 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter",
"invalid parameter name"); | 2199 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter",
"invalid parameter name"); |
2067 return WebGLGetInfo(); | 2200 return WebGLGetInfo(); |
2068 } | 2201 } |
2069 | 2202 |
| 2203 if (!isAcquiredForReading("getBufferParameter", buffer)) { |
| 2204 return WebGLGetInfo(); |
| 2205 } |
| 2206 |
2070 GC3Dint value = 0; | 2207 GC3Dint value = 0; |
2071 m_context->getBufferParameteriv(target, pname, &value); | 2208 m_context->getBufferParameteriv(target, pname, &value); |
2072 if (pname == GraphicsContext3D::BUFFER_SIZE) | 2209 if (pname == GraphicsContext3D::BUFFER_SIZE) |
2073 return WebGLGetInfo(value); | 2210 return WebGLGetInfo(value); |
2074 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2211 return WebGLGetInfo(static_cast<unsigned int>(value)); |
2075 } | 2212 } |
2076 | 2213 |
2077 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() | 2214 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() |
2078 { | 2215 { |
2079 if (isContextLost()) | 2216 if (isContextLost()) |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 return WebGLGetInfo(value); | 2565 return WebGLGetInfo(value); |
2429 } | 2566 } |
2430 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name"); | 2567 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name"); |
2431 return WebGLGetInfo(); | 2568 return WebGLGetInfo(); |
2432 } | 2569 } |
2433 } | 2570 } |
2434 | 2571 |
2435 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G
C3Denum pname, ExceptionCode& ec) | 2572 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G
C3Denum pname, ExceptionCode& ec) |
2436 { | 2573 { |
2437 UNUSED_PARAM(ec); | 2574 UNUSED_PARAM(ec); |
2438 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) | 2575 if (isContextLost() || !validateWebGLSharedObject("getProgramParameter", pro
gram, WebGLSharedObject::ReadOnly)) |
2439 return WebGLGetInfo(); | 2576 return WebGLGetInfo(); |
2440 | 2577 |
2441 GC3Dint value = 0; | 2578 GC3Dint value = 0; |
2442 switch (pname) { | 2579 switch (pname) { |
2443 case GraphicsContext3D::DELETE_STATUS: | 2580 case GraphicsContext3D::DELETE_STATUS: |
2444 return WebGLGetInfo(program->isDeleted()); | 2581 return WebGLGetInfo(program->isDeleted()); |
2445 case GraphicsContext3D::VALIDATE_STATUS: | 2582 case GraphicsContext3D::VALIDATE_STATUS: |
2446 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2583 m_context->getProgramiv(objectOrZero(program), pname, &value); |
2447 return WebGLGetInfo(static_cast<bool>(value)); | 2584 return WebGLGetInfo(static_cast<bool>(value)); |
2448 case GraphicsContext3D::LINK_STATUS: | 2585 case GraphicsContext3D::LINK_STATUS: |
2449 return WebGLGetInfo(program->getLinkStatus()); | 2586 return WebGLGetInfo(program->getLinkStatus(this)); |
2450 case GraphicsContext3D::ATTACHED_SHADERS: | 2587 case GraphicsContext3D::ATTACHED_SHADERS: |
2451 case GraphicsContext3D::ACTIVE_ATTRIBUTES: | 2588 case GraphicsContext3D::ACTIVE_ATTRIBUTES: |
2452 case GraphicsContext3D::ACTIVE_UNIFORMS: | 2589 case GraphicsContext3D::ACTIVE_UNIFORMS: |
2453 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2590 m_context->getProgramiv(objectOrZero(program), pname, &value); |
2454 return WebGLGetInfo(value); | 2591 return WebGLGetInfo(value); |
2455 default: | 2592 default: |
2456 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter"
, "invalid parameter name"); | 2593 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter"
, "invalid parameter name"); |
2457 return WebGLGetInfo(); | 2594 return WebGLGetInfo(); |
2458 } | 2595 } |
2459 } | 2596 } |
2460 | 2597 |
2461 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, Exception
Code& ec) | 2598 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, Exception
Code& ec) |
2462 { | 2599 { |
2463 UNUSED_PARAM(ec); | 2600 UNUSED_PARAM(ec); |
2464 if (isContextLost()) | 2601 if (isContextLost()) |
2465 return String(); | 2602 return String(); |
2466 if (!validateWebGLObject("getProgramInfoLog", program)) | 2603 if (!validateWebGLSharedObject("getProgramInfoLog", program, WebGLSharedObje
ct::ReadOnly)) |
2467 return ""; | 2604 return ""; |
2468 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); | 2605 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); |
2469 } | 2606 } |
2470 | 2607 |
2471 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC
3Denum pname, ExceptionCode& ec) | 2608 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC
3Denum pname, ExceptionCode& ec) |
2472 { | 2609 { |
2473 UNUSED_PARAM(ec); | 2610 UNUSED_PARAM(ec); |
2474 if (isContextLost()) | 2611 if (isContextLost()) |
2475 return WebGLGetInfo(); | 2612 return WebGLGetInfo(); |
2476 if (target != GraphicsContext3D::RENDERBUFFER) { | 2613 if (target != GraphicsContext3D::RENDERBUFFER) { |
2477 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam
eter", "invalid target"); | 2614 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam
eter", "invalid target"); |
2478 return WebGLGetInfo(); | 2615 return WebGLGetInfo(); |
2479 } | 2616 } |
2480 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 2617 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
2481 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer
Parameter", "no renderbuffer bound"); | 2618 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer
Parameter", "no renderbuffer bound"); |
2482 return WebGLGetInfo(); | 2619 return WebGLGetInfo(); |
2483 } | 2620 } |
2484 | 2621 |
| 2622 if (!isAcquiredForReading("getRenderbufferParameter", m_renderbufferBinding.
get())) { |
| 2623 return WebGLGetInfo(); |
| 2624 } |
| 2625 |
2485 GC3Dint value = 0; | 2626 GC3Dint value = 0; |
2486 switch (pname) { | 2627 switch (pname) { |
2487 case GraphicsContext3D::RENDERBUFFER_WIDTH: | 2628 case GraphicsContext3D::RENDERBUFFER_WIDTH: |
2488 case GraphicsContext3D::RENDERBUFFER_HEIGHT: | 2629 case GraphicsContext3D::RENDERBUFFER_HEIGHT: |
2489 case GraphicsContext3D::RENDERBUFFER_RED_SIZE: | 2630 case GraphicsContext3D::RENDERBUFFER_RED_SIZE: |
2490 case GraphicsContext3D::RENDERBUFFER_GREEN_SIZE: | 2631 case GraphicsContext3D::RENDERBUFFER_GREEN_SIZE: |
2491 case GraphicsContext3D::RENDERBUFFER_BLUE_SIZE: | 2632 case GraphicsContext3D::RENDERBUFFER_BLUE_SIZE: |
2492 case GraphicsContext3D::RENDERBUFFER_ALPHA_SIZE: | 2633 case GraphicsContext3D::RENDERBUFFER_ALPHA_SIZE: |
2493 case GraphicsContext3D::RENDERBUFFER_DEPTH_SIZE: | 2634 case GraphicsContext3D::RENDERBUFFER_DEPTH_SIZE: |
2494 m_context->getRenderbufferParameteriv(target, pname, &value); | 2635 m_context->getRenderbufferParameteriv(target, pname, &value); |
(...skipping 11 matching lines...) Expand all Loading... |
2506 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); | 2647 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); |
2507 default: | 2648 default: |
2508 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam
eter", "invalid parameter name"); | 2649 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam
eter", "invalid parameter name"); |
2509 return WebGLGetInfo(); | 2650 return WebGLGetInfo(); |
2510 } | 2651 } |
2511 } | 2652 } |
2512 | 2653 |
2513 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D
enum pname, ExceptionCode& ec) | 2654 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D
enum pname, ExceptionCode& ec) |
2514 { | 2655 { |
2515 UNUSED_PARAM(ec); | 2656 UNUSED_PARAM(ec); |
2516 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) | 2657 if (isContextLost() || !validateWebGLSharedObject("getShaderParameter", shad
er, WebGLSharedObject::ReadOnly)) |
2517 return WebGLGetInfo(); | 2658 return WebGLGetInfo(); |
2518 GC3Dint value = 0; | 2659 GC3Dint value = 0; |
2519 switch (pname) { | 2660 switch (pname) { |
2520 case GraphicsContext3D::DELETE_STATUS: | 2661 case GraphicsContext3D::DELETE_STATUS: |
2521 return WebGLGetInfo(shader->isDeleted()); | 2662 return WebGLGetInfo(shader->isDeleted()); |
2522 case GraphicsContext3D::COMPILE_STATUS: | 2663 case GraphicsContext3D::COMPILE_STATUS: |
2523 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2664 m_context->getShaderiv(objectOrZero(shader), pname, &value); |
2524 return WebGLGetInfo(static_cast<bool>(value)); | 2665 return WebGLGetInfo(static_cast<bool>(value)); |
2525 case GraphicsContext3D::SHADER_TYPE: | 2666 case GraphicsContext3D::SHADER_TYPE: |
2526 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2667 m_context->getShaderiv(objectOrZero(shader), pname, &value); |
2527 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2668 return WebGLGetInfo(static_cast<unsigned int>(value)); |
2528 default: | 2669 default: |
2529 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter",
"invalid parameter name"); | 2670 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter",
"invalid parameter name"); |
2530 return WebGLGetInfo(); | 2671 return WebGLGetInfo(); |
2531 } | 2672 } |
2532 } | 2673 } |
2533 | 2674 |
2534 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCod
e& ec) | 2675 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCod
e& ec) |
2535 { | 2676 { |
2536 UNUSED_PARAM(ec); | 2677 UNUSED_PARAM(ec); |
2537 if (isContextLost()) | 2678 if (isContextLost()) |
2538 return String(); | 2679 return String(); |
2539 if (!validateWebGLObject("getShaderInfoLog", shader)) | 2680 if (!validateWebGLSharedObject("getShaderInfoLog", shader, WebGLSharedObject
::ReadOnly)) |
2540 return ""; | 2681 return ""; |
2541 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); | 2682 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); |
2542 } | 2683 } |
2543 | 2684 |
2544 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision
Format(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode& ec) | 2685 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision
Format(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode& ec) |
2545 { | 2686 { |
2546 UNUSED_PARAM(ec); | 2687 UNUSED_PARAM(ec); |
2547 if (isContextLost()) | 2688 if (isContextLost()) |
2548 return 0; | 2689 return 0; |
2549 switch (shaderType) { | 2690 switch (shaderType) { |
(...skipping 21 matching lines...) Expand all Loading... |
2571 GC3Dint precision = 0; | 2712 GC3Dint precision = 0; |
2572 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); | 2713 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); |
2573 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 2714 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); |
2574 } | 2715 } |
2575 | 2716 |
2576 String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode
& ec) | 2717 String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode
& ec) |
2577 { | 2718 { |
2578 UNUSED_PARAM(ec); | 2719 UNUSED_PARAM(ec); |
2579 if (isContextLost()) | 2720 if (isContextLost()) |
2580 return String(); | 2721 return String(); |
2581 if (!validateWebGLObject("getShaderSource", shader)) | 2722 if (!validateWebGLSharedObject("getShaderSource", shader, WebGLSharedObject:
:ReadOnly)) |
2582 return ""; | 2723 return ""; |
2583 return ensureNotNull(shader->getSource()); | 2724 return ensureNotNull(shader->getSource()); |
2584 } | 2725 } |
2585 | 2726 |
2586 Vector<String> WebGLRenderingContext::getSupportedExtensions() | 2727 Vector<String> WebGLRenderingContext::getSupportedExtensions() |
2587 { | 2728 { |
2588 Vector<String> result; | 2729 Vector<String> result; |
2589 if (isContextLost()) | 2730 if (isContextLost()) |
2590 return result; | 2731 return result; |
2591 | 2732 |
2592 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2733 for (size_t i = 0; i < m_extensions.size(); ++i) { |
2593 ExtensionTracker* tracker = m_extensions[i]; | 2734 ExtensionTracker* tracker = m_extensions[i]; |
2594 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) | 2735 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) |
2595 continue; | 2736 continue; |
2596 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtensions
Enabled()) | 2737 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtensions
Enabled()) |
2597 continue; | 2738 continue; |
2598 if (tracker->supported(this)) | 2739 if (tracker->supported(this)) |
2599 result.append(String(tracker->getPrefixed() ? "WEBKIT_" : "") + tra
cker->getExtensionName()); | 2740 result.append(String(tracker->getPrefixed() ? "WEBKIT_" : "") + tra
cker->getExtensionName()); |
2600 } | 2741 } |
2601 | 2742 |
2602 return result; | 2743 return result; |
2603 } | 2744 } |
2604 | 2745 |
2605 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn
ame, ExceptionCode& ec) | 2746 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn
ame, ExceptionCode& ec) |
2606 { | 2747 { |
2607 UNUSED_PARAM(ec); | 2748 UNUSED_PARAM(ec); |
2608 if (isContextLost()) | 2749 if (isContextLost()) |
2609 return WebGLGetInfo(); | 2750 return WebGLGetInfo(); |
2610 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false)
; | 2751 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false,
WebGLSharedObject::ReadOnly); |
2611 if (!tex) | 2752 if (!tex) |
2612 return WebGLGetInfo(); | 2753 return WebGLGetInfo(); |
2613 GC3Dint value = 0; | 2754 GC3Dint value = 0; |
2614 switch (pname) { | 2755 switch (pname) { |
2615 case GraphicsContext3D::TEXTURE_MAG_FILTER: | 2756 case GraphicsContext3D::TEXTURE_MAG_FILTER: |
2616 case GraphicsContext3D::TEXTURE_MIN_FILTER: | 2757 case GraphicsContext3D::TEXTURE_MIN_FILTER: |
2617 case GraphicsContext3D::TEXTURE_WRAP_S: | 2758 case GraphicsContext3D::TEXTURE_WRAP_S: |
2618 case GraphicsContext3D::TEXTURE_WRAP_T: | 2759 case GraphicsContext3D::TEXTURE_WRAP_T: |
2619 m_context->getTexParameteriv(target, pname, &value); | 2760 m_context->getTexParameteriv(target, pname, &value); |
2620 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2761 return WebGLGetInfo(static_cast<unsigned int>(value)); |
2621 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr
opic | 2762 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr
opic |
2622 if (m_extTextureFilterAnisotropic) { | 2763 if (m_extTextureFilterAnisotropic) { |
2623 m_context->getTexParameteriv(target, pname, &value); | 2764 m_context->getTexParameteriv(target, pname, &value); |
2624 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2765 return WebGLGetInfo(static_cast<unsigned int>(value)); |
2625 } | 2766 } |
2626 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i
nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); | 2767 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i
nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); |
2627 return WebGLGetInfo(); | 2768 return WebGLGetInfo(); |
2628 default: | 2769 default: |
2629 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i
nvalid parameter name"); | 2770 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i
nvalid parameter name"); |
2630 return WebGLGetInfo(); | 2771 return WebGLGetInfo(); |
2631 } | 2772 } |
2632 } | 2773 } |
2633 | 2774 |
2634 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
LUniformLocation* uniformLocation, ExceptionCode& ec) | 2775 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
LUniformLocation* uniformLocation, ExceptionCode& ec) |
2635 { | 2776 { |
2636 UNUSED_PARAM(ec); | 2777 UNUSED_PARAM(ec); |
2637 if (isContextLost() || !validateWebGLObject("getUniform", program)) | 2778 if (isContextLost() || !validateWebGLSharedObject("getUniform", program, Web
GLSharedObject::ReadOnly)) |
2638 return WebGLGetInfo(); | 2779 return WebGLGetInfo(); |
2639 if (!uniformLocation || uniformLocation->program() != program) { | 2780 if (!uniformLocation || uniformLocation->program() != program) { |
2640 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n
o uniformlocation or not valid for this program"); | 2781 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n
o uniformlocation or not valid for this program"); |
2641 return WebGLGetInfo(); | 2782 return WebGLGetInfo(); |
2642 } | 2783 } |
2643 GC3Dint location = uniformLocation->location(); | 2784 GC3Dint location = uniformLocation->location(); |
2644 | 2785 |
2645 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it | 2786 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it |
2646 GC3Dint activeUniforms = 0; | 2787 GC3Dint activeUniforms = 0; |
2647 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNI
FORMS, &activeUniforms); | 2788 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNI
FORMS, &activeUniforms); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 } | 2911 } |
2771 } | 2912 } |
2772 // If we get here, something went wrong in our unfortunately complex logic a
bove | 2913 // If we get here, something went wrong in our unfortunately complex logic a
bove |
2773 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e
rror"); | 2914 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e
rror"); |
2774 return WebGLGetInfo(); | 2915 return WebGLGetInfo(); |
2775 } | 2916 } |
2776 | 2917 |
2777 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
Program* program, const String& name, ExceptionCode& ec) | 2918 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
Program* program, const String& name, ExceptionCode& ec) |
2778 { | 2919 { |
2779 UNUSED_PARAM(ec); | 2920 UNUSED_PARAM(ec); |
2780 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) | 2921 if (isContextLost() || !validateWebGLSharedObject("getUniformLocation", prog
ram, WebGLSharedObject::ReadOnly)) |
2781 return 0; | 2922 return 0; |
2782 if (!validateLocationLength("getUniformLocation", name)) | 2923 if (!validateLocationLength("getUniformLocation", name)) |
2783 return 0; | 2924 return 0; |
2784 if (!validateString("getUniformLocation", name)) | 2925 if (!validateString("getUniformLocation", name)) |
2785 return 0; | 2926 return 0; |
2786 if (isPrefixReserved(name)) | 2927 if (isPrefixReserved(name)) |
2787 return 0; | 2928 return 0; |
2788 if (!program->getLinkStatus()) { | 2929 if (!program->getLinkStatus(this)) { |
2789 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat
ion", "program not linked"); | 2930 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat
ion", "program not linked"); |
2790 return 0; | 2931 return 0; |
2791 } | 2932 } |
2792 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program
), name); | 2933 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program
), name); |
2793 if (uniformLocation == -1) | 2934 if (uniformLocation == -1) |
2794 return 0; | 2935 return 0; |
2795 return WebGLUniformLocation::create(program, uniformLocation); | 2936 return WebGLUniformLocation::create(program, uniformLocation); |
2796 } | 2937 } |
2797 | 2938 |
2798 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna
me, ExceptionCode& ec) | 2939 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna
me, ExceptionCode& ec) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2865 { | 3006 { |
2866 if (!buffer || isContextLost()) | 3007 if (!buffer || isContextLost()) |
2867 return 0; | 3008 return 0; |
2868 | 3009 |
2869 if (!buffer->hasEverBeenBound()) | 3010 if (!buffer->hasEverBeenBound()) |
2870 return 0; | 3011 return 0; |
2871 | 3012 |
2872 return m_context->isBuffer(buffer->object()); | 3013 return m_context->isBuffer(buffer->object()); |
2873 } | 3014 } |
2874 | 3015 |
2875 bool WebGLRenderingContext::isContextLost() | 3016 bool WebGLRenderingContext::isContextLost() const |
2876 { | 3017 { |
2877 return m_contextLost; | 3018 return m_contextLost; |
2878 } | 3019 } |
2879 | 3020 |
2880 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) | 3021 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) |
2881 { | 3022 { |
2882 if (isContextLost() || !validateCapability("isEnabled", cap)) | 3023 if (isContextLost() || !validateCapability("isEnabled", cap)) |
2883 return 0; | 3024 return 0; |
2884 if (cap == GraphicsContext3D::STENCIL_TEST) | 3025 if (cap == GraphicsContext3D::STENCIL_TEST) |
2885 return m_stencilEnabled; | 3026 return m_stencilEnabled; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 void WebGLRenderingContext::lineWidth(GC3Dfloat width) | 3079 void WebGLRenderingContext::lineWidth(GC3Dfloat width) |
2939 { | 3080 { |
2940 if (isContextLost()) | 3081 if (isContextLost()) |
2941 return; | 3082 return; |
2942 m_context->lineWidth(width); | 3083 m_context->lineWidth(width); |
2943 } | 3084 } |
2944 | 3085 |
2945 void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec
) | 3086 void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec
) |
2946 { | 3087 { |
2947 UNUSED_PARAM(ec); | 3088 UNUSED_PARAM(ec); |
2948 if (isContextLost() || !validateWebGLObject("linkProgram", program)) | 3089 if (isContextLost() || !validateWebGLSharedObject("linkProgram", program, We
bGLSharedObject::Exclusive)) |
2949 return; | 3090 return; |
2950 | 3091 |
2951 m_context->linkProgram(objectOrZero(program)); | 3092 m_context->linkProgram(objectOrZero(program)); |
2952 program->increaseLinkCount(); | 3093 program->increaseLinkCount(); |
2953 } | 3094 } |
2954 | 3095 |
2955 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) | 3096 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) |
2956 { | 3097 { |
2957 if (isContextLost()) | 3098 if (isContextLost()) |
2958 return; | 3099 return; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED
_BYTE) { | 3172 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED
_BYTE) { |
3032 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "f
ormat not RGBA or type not UNSIGNED_BYTE"); | 3173 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "f
ormat not RGBA or type not UNSIGNED_BYTE"); |
3033 return; | 3174 return; |
3034 } | 3175 } |
3035 // Validate array type against pixel type. | 3176 // Validate array type against pixel type. |
3036 if (pixels->getType() != ArrayBufferView::TypeUint8) { | 3177 if (pixels->getType() != ArrayBufferView::TypeUint8) { |
3037 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A
rrayBufferView not Uint8Array"); | 3178 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A
rrayBufferView not Uint8Array"); |
3038 return; | 3179 return; |
3039 } | 3180 } |
3040 const char* reason = "framebuffer incomplete"; | 3181 const char* reason = "framebuffer incomplete"; |
3041 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 3182 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare
dObject::ReadOnly, &reason)) { |
3042 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea
dPixels", reason); | 3183 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea
dPixels", reason); |
3043 return; | 3184 return; |
3044 } | 3185 } |
3045 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3186 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
3046 unsigned int totalBytesRequired = 0; | 3187 unsigned int totalBytesRequired = 0; |
3047 unsigned int padding = 0; | 3188 unsigned int padding = 0; |
3048 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei
ght, m_packAlignment, &totalBytesRequired, &padding); | 3189 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei
ght, m_packAlignment, &totalBytesRequired, &padding); |
3049 if (error != GraphicsContext3D::NO_ERROR) { | 3190 if (error != GraphicsContext3D::NO_ERROR) { |
3050 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3191 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
3051 return; | 3192 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 if (isContextLost()) | 3225 if (isContextLost()) |
3085 return; | 3226 return; |
3086 if (target != GraphicsContext3D::RENDERBUFFER) { | 3227 if (target != GraphicsContext3D::RENDERBUFFER) { |
3087 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage"
, "invalid target"); | 3228 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage"
, "invalid target"); |
3088 return; | 3229 return; |
3089 } | 3230 } |
3090 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 3231 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
3091 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto
rage", "no bound renderbuffer"); | 3232 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto
rage", "no bound renderbuffer"); |
3092 return; | 3233 return; |
3093 } | 3234 } |
| 3235 if (!isAcquiredForModification("renderbufferStorage", m_renderbufferBinding.
get())) |
| 3236 return; |
3094 if (!validateSize("renderbufferStorage", width, height)) | 3237 if (!validateSize("renderbufferStorage", width, height)) |
3095 return; | 3238 return; |
3096 switch (internalformat) { | 3239 switch (internalformat) { |
3097 case GraphicsContext3D::DEPTH_COMPONENT16: | 3240 case GraphicsContext3D::DEPTH_COMPONENT16: |
3098 case GraphicsContext3D::RGBA4: | 3241 case GraphicsContext3D::RGBA4: |
3099 case GraphicsContext3D::RGB5_A1: | 3242 case GraphicsContext3D::RGB5_A1: |
3100 case GraphicsContext3D::RGB565: | 3243 case GraphicsContext3D::RGB565: |
3101 case GraphicsContext3D::STENCIL_INDEX8: | 3244 case GraphicsContext3D::STENCIL_INDEX8: |
3102 m_context->renderbufferStorage(target, internalformat, width, height); | 3245 m_context->renderbufferStorage(target, internalformat, width, height); |
3103 m_renderbufferBinding->setInternalFormat(internalformat); | 3246 m_renderbufferBinding->setInternalFormat(internalformat); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3142 if (isContextLost()) | 3285 if (isContextLost()) |
3143 return; | 3286 return; |
3144 if (!validateSize("scissor", width, height)) | 3287 if (!validateSize("scissor", width, height)) |
3145 return; | 3288 return; |
3146 m_context->scissor(x, y, width, height); | 3289 m_context->scissor(x, y, width, height); |
3147 } | 3290 } |
3148 | 3291 |
3149 void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri
ng, ExceptionCode& ec) | 3292 void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri
ng, ExceptionCode& ec) |
3150 { | 3293 { |
3151 UNUSED_PARAM(ec); | 3294 UNUSED_PARAM(ec); |
3152 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 3295 if (isContextLost() || !validateWebGLSharedObject("shaderSource", shader, We
bGLSharedObject::Exclusive)) |
3153 return; | 3296 return; |
3154 String stringWithoutComments = StripComments(string).result(); | 3297 String stringWithoutComments = StripComments(string).result(); |
3155 if (!validateString("shaderSource", stringWithoutComments)) | 3298 if (!validateString("shaderSource", stringWithoutComments)) |
3156 return; | 3299 return; |
3157 shader->setSource(string); | 3300 shader->setSource(string); |
3158 m_context->shaderSource(objectOrZero(shader), stringWithoutComments); | 3301 m_context->shaderSource(objectOrZero(shader), stringWithoutComments); |
3159 } | 3302 } |
3160 | 3303 |
3161 void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mas
k) | 3304 void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mas
k) |
3162 { | 3305 { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3242 if (isContextLost()) | 3385 if (isContextLost()) |
3243 return; | 3386 return; |
3244 m_context->stencilOpSeparate(face, fail, zfail, zpass); | 3387 m_context->stencilOpSeparate(face, fail, zfail, zpass); |
3245 } | 3388 } |
3246 | 3389 |
3247 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) | 3390 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) |
3248 { | 3391 { |
3249 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 3392 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
3250 // FIXME: For now we ignore any errors returned | 3393 // FIXME: For now we ignore any errors returned |
3251 ec = 0; | 3394 ec = 0; |
3252 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); | 3395 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true, WebGL
SharedObject::Exclusive); |
3253 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev
el, internalformat, width, height, border, format, type)); | 3396 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev
el, internalformat, width, height, border, format, type)); |
3254 ASSERT(tex); | 3397 ASSERT(tex); |
3255 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); | 3398 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); |
3256 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); | 3399 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); |
3257 m_context->texImage2D(target, level, internalformat, width, height, | 3400 m_context->texImage2D(target, level, internalformat, width, height, |
3258 border, format, type, pixels); | 3401 border, format, type, pixels); |
3259 tex->setLevelInfo(target, level, internalformat, width, height, type); | 3402 tex->setLevelInfo(target, level, internalformat, width, height, type); |
3260 } | 3403 } |
3261 | 3404 |
3262 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) | 3405 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 Loading... |
3288 texImage2DBase(target, level, internalformat, image->width(), image->height(
), 0, format, type, needConversion ? data.data() : imagePixelData, ec); | 3431 texImage2DBase(target, level, internalformat, image->width(), image->height(
), 0, format, type, needConversion ? data.data() : imagePixelData, ec); |
3289 if (m_unpackAlignment != 1) | 3432 if (m_unpackAlignment != 1) |
3290 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig
nment); | 3433 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig
nment); |
3291 } | 3434 } |
3292 | 3435 |
3293 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) | 3436 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) |
3294 { | 3437 { |
3295 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, border, format, type)) | 3438 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, border, format, type)) |
3296 return false; | 3439 return false; |
3297 | 3440 |
3298 WebGLTexture* texture = validateTextureBinding(functionName, target, true); | 3441 WebGLTexture* texture = validateTextureBinding(functionName, target, true, W
ebGLSharedObject::Exclusive); |
3299 if (!texture) | 3442 if (!texture) |
3300 return false; | 3443 return false; |
3301 | 3444 |
3302 if (functionType == NotTexSubImage2D) { | 3445 if (functionType == NotTexSubImage2D) { |
3303 if (level && WebGLTexture::isNPOT(width, height)) { | 3446 if (level && WebGLTexture::isNPOT(width, height)) { |
3304 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l
evel > 0 not power of 2"); | 3447 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l
evel > 0 not power of 2"); |
3305 return false; | 3448 return false; |
3306 } | 3449 } |
3307 // For SourceArrayBufferView, function validateTexFuncData() would handl
e whether to validate the SettableTexFormat | 3450 // For SourceArrayBufferView, function validateTexFuncData() would handl
e whether to validate the SettableTexFormat |
3308 // by checking if the ArrayBufferView is null or not. | 3451 // by checking if the ArrayBufferView is null or not. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 texImage2DImpl(target, level, internalformat, format, type, imageForRender,
GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); | 3542 texImage2DImpl(target, level, internalformat, format, type, imageForRender,
GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); |
3400 } | 3543 } |
3401 | 3544 |
3402 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum
internalformat, | 3545 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum
internalformat, |
3403 GC3Denum format, GC3Denum type, HTMLCanva
sElement* canvas, ExceptionCode& ec) | 3546 GC3Denum format, GC3Denum type, HTMLCanva
sElement* canvas, ExceptionCode& ec) |
3404 { | 3547 { |
3405 ec = 0; | 3548 ec = 0; |
3406 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, ec)
|| !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvasElement, tar
get, level, internalformat, canvas->width(), canvas->height(), 0, format, type,
0, 0)) | 3549 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, ec)
|| !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvasElement, tar
get, level, internalformat, canvas->width(), canvas->height(), 0, format, type,
0, 0)) |
3407 return; | 3550 return; |
3408 | 3551 |
3409 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3552 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true, W
ebGLSharedObject::Exclusive); |
3410 // If possible, copy from the canvas element directly to the texture | 3553 // If possible, copy from the canvas element directly to the texture |
3411 // via the GPU, without a read-back to system memory. | 3554 // via the GPU, without a read-back to system memory. |
3412 if (GraphicsContext3D::TEXTURE_2D == target && texture) { | 3555 if (GraphicsContext3D::TEXTURE_2D == target && texture) { |
3413 ImageBuffer* buffer = canvas->buffer(); | 3556 ImageBuffer* buffer = canvas->buffer(); |
3414 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->o
bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ | 3557 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->o
bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ |
3415 texture->setLevelInfo(target, level, internalformat, canvas->width()
, canvas->height(), type); | 3558 texture->setLevelInfo(target, level, internalformat, canvas->width()
, canvas->height(), type); |
3416 return; | 3559 return; |
3417 } | 3560 } |
3418 } | 3561 } |
3419 | 3562 |
(...skipping 21 matching lines...) Expand all Loading... |
3441 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum
internalformat, | 3584 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum
internalformat, |
3442 GC3Denum format, GC3Denum type, HTMLVideo
Element* video, ExceptionCode& ec) | 3585 GC3Denum format, GC3Denum type, HTMLVideo
Element* video, ExceptionCode& ec) |
3443 { | 3586 { |
3444 ec = 0; | 3587 ec = 0; |
3445 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, ec) | 3588 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, ec) |
3446 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) | 3589 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) |
3447 return; | 3590 return; |
3448 | 3591 |
3449 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 3592 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
3450 // Otherwise, it will fall back to the normal SW path. | 3593 // Otherwise, it will fall back to the normal SW path. |
3451 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3594 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true, W
ebGLSharedObject::Exclusive); |
3452 if (GraphicsContext3D::TEXTURE_2D == target && texture) { | 3595 if (GraphicsContext3D::TEXTURE_2D == target && texture) { |
3453 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o
bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ | 3596 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o
bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ |
3454 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), type); | 3597 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), type); |
3455 return; | 3598 return; |
3456 } | 3599 } |
3457 } | 3600 } |
3458 | 3601 |
3459 // Normal pure SW path. | 3602 // Normal pure SW path. |
3460 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e(), ec); | 3603 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e(), ec); |
3461 if (!image) | 3604 if (!image) |
3462 return; | 3605 return; |
3463 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra
phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); | 3606 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra
phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec); |
3464 } | 3607 } |
3465 | 3608 |
3466 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl
oat paramf, GC3Dint parami, bool isFloat) | 3609 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl
oat paramf, GC3Dint parami, bool isFloat) |
3467 { | 3610 { |
3468 if (isContextLost()) | 3611 if (isContextLost()) |
3469 return; | 3612 return; |
3470 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); | 3613 WebGLTexture* tex = validateTextureBinding("texParameter", target, false, We
bGLSharedObject::Exclusive); |
3471 if (!tex) | 3614 if (!tex) |
3472 return; | 3615 return; |
3473 switch (pname) { | 3616 switch (pname) { |
3474 case GraphicsContext3D::TEXTURE_MIN_FILTER: | 3617 case GraphicsContext3D::TEXTURE_MIN_FILTER: |
3475 case GraphicsContext3D::TEXTURE_MAG_FILTER: | 3618 case GraphicsContext3D::TEXTURE_MAG_FILTER: |
3476 break; | 3619 break; |
3477 case GraphicsContext3D::TEXTURE_WRAP_S: | 3620 case GraphicsContext3D::TEXTURE_WRAP_S: |
3478 case GraphicsContext3D::TEXTURE_WRAP_T: | 3621 case GraphicsContext3D::TEXTURE_WRAP_T: |
3479 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf !=
GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) | 3622 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf !=
GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) |
3480 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami
!= GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT))
{ | 3623 || (!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 Loading... |
3512 } | 3655 } |
3513 | 3656 |
3514 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) | 3657 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) |
3515 { | 3658 { |
3516 // FIXME: For now we ignore any errors returned | 3659 // FIXME: For now we ignore any errors returned |
3517 ec = 0; | 3660 ec = 0; |
3518 ASSERT(!isContextLost()); | 3661 ASSERT(!isContextLost()); |
3519 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, lev
el, format, width, height, 0, format, type)); | 3662 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, lev
el, format, width, height, 0, format, type)); |
3520 ASSERT(validateSize("texSubImage2D", xoffset, yoffset)); | 3663 ASSERT(validateSize("texSubImage2D", xoffset, yoffset)); |
3521 ASSERT(validateSettableTexFormat("texSubImage2D", format)); | 3664 ASSERT(validateSettableTexFormat("texSubImage2D", format)); |
3522 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); | 3665 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true, We
bGLSharedObject::Exclusive); |
3523 if (!tex) { | 3666 if (!tex) { |
3524 ASSERT_NOT_REACHED(); | 3667 ASSERT_NOT_REACHED(); |
3525 return; | 3668 return; |
3526 } | 3669 } |
3527 ASSERT((xoffset + width) >= 0); | 3670 ASSERT((xoffset + width) >= 0); |
3528 ASSERT((yoffset + height) >= 0); | 3671 ASSERT((yoffset + height) >= 0); |
3529 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); | 3672 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); |
3530 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); | 3673 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); |
3531 ASSERT(tex->getInternalFormat(target, level) == format); | 3674 ASSERT(tex->getInternalFormat(target, level) == format); |
3532 ASSERT(tex->getType(target, level) == type); | 3675 ASSERT(tex->getType(target, level) == type); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3960 UNUSED_PARAM(ec); | 4103 UNUSED_PARAM(ec); |
3961 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv",
location, transpose, v, size, 16)) | 4104 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv",
location, transpose, v, size, 16)) |
3962 return; | 4105 return; |
3963 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); | 4106 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); |
3964 } | 4107 } |
3965 | 4108 |
3966 void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec) | 4109 void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec) |
3967 { | 4110 { |
3968 UNUSED_PARAM(ec); | 4111 UNUSED_PARAM(ec); |
3969 bool deleted; | 4112 bool deleted; |
3970 if (!checkObjectToBeBound("useProgram", program, deleted)) | 4113 bool boundSinceLastAcquire; |
| 4114 if (!checkSharedObjectToBeBound("useProgram", program, deleted, boundSinceLa
stAcquire)) |
3971 return; | 4115 return; |
3972 if (deleted) | 4116 if (deleted) |
3973 program = 0; | 4117 program = 0; |
3974 if (program && !program->getLinkStatus()) { | 4118 if (program && !program->getLinkStatus(this)) { |
3975 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p
rogram not valid"); | 4119 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p
rogram not valid"); |
3976 return; | 4120 return; |
3977 } | 4121 } |
3978 if (m_currentProgram != program) { | 4122 if (m_currentProgram != program) { |
3979 if (m_currentProgram) | 4123 if (m_currentProgram) |
3980 m_currentProgram->onDetached(graphicsContext3D()); | 4124 m_currentProgram->onDetached(graphicsContext3D()); |
3981 m_currentProgram = program; | 4125 m_currentProgram = program; |
3982 m_context->useProgram(objectOrZero(program)); | 4126 m_context->useProgram(objectOrZero(program)); |
3983 if (program) | 4127 if (program) |
3984 program->onAttached(); | 4128 program->onAttached(); |
3985 } | 4129 } |
| 4130 if (program && !boundSinceLastAcquire) { |
| 4131 program->markAsBoundSinceLastAcquireForContext(this); |
| 4132 } |
3986 } | 4133 } |
3987 | 4134 |
3988 void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode
& ec) | 4135 void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode
& ec) |
3989 { | 4136 { |
3990 UNUSED_PARAM(ec); | 4137 UNUSED_PARAM(ec); |
3991 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 4138 if (isContextLost() || !validateWebGLSharedObject("validateProgram", program
, WebGLSharedObject::ReadOnly)) |
3992 return; | 4139 return; |
3993 m_context->validateProgram(objectOrZero(program)); | 4140 m_context->validateProgram(objectOrZero(program)); |
3994 } | 4141 } |
3995 | 4142 |
3996 void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) | 4143 void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) |
3997 { | 4144 { |
3998 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); | 4145 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); |
3999 } | 4146 } |
4000 | 4147 |
4001 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v) | 4148 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4086 if (!typeSize) { | 4233 if (!typeSize) { |
4087 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer"
, "invalid type"); | 4234 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer"
, "invalid type"); |
4088 return; | 4235 return; |
4089 } | 4236 } |
4090 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { | 4237 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { |
4091 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi
nter", "stride or offset not valid for type"); | 4238 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi
nter", "stride or offset not valid for type"); |
4092 return; | 4239 return; |
4093 } | 4240 } |
4094 GC3Dsizei bytesPerElement = size * typeSize; | 4241 GC3Dsizei bytesPerElement = size * typeSize; |
4095 | 4242 |
| 4243 if (!isAcquiredForReading("vertexAttribPointer", m_boundArrayBuffer.get()))
{ |
| 4244 return; |
| 4245 } |
4096 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); | 4246 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); |
4097 m_context->vertexAttribPointer(index, size, type, normalized, stride, static
_cast<GC3Dintptr>(offset)); | 4247 m_context->vertexAttribPointer(index, size, type, normalized, stride, static
_cast<GC3Dintptr>(offset)); |
4098 } | 4248 } |
4099 | 4249 |
4100 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di
visor) | 4250 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di
visor) |
4101 { | 4251 { |
4102 if (isContextLost()) | 4252 if (isContextLost()) |
4103 return; | 4253 return; |
4104 | 4254 |
4105 if (index >= m_maxVertexAttribs) { | 4255 if (index >= m_maxVertexAttribs) { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4419 return m_drawingBuffer->size().width(); | 4569 return m_drawingBuffer->size().width(); |
4420 } | 4570 } |
4421 | 4571 |
4422 int WebGLRenderingContext::getBoundFramebufferHeight() | 4572 int WebGLRenderingContext::getBoundFramebufferHeight() |
4423 { | 4573 { |
4424 if (m_framebufferBinding && m_framebufferBinding->object()) | 4574 if (m_framebufferBinding && m_framebufferBinding->object()) |
4425 return m_framebufferBinding->getColorBufferHeight(); | 4575 return m_framebufferBinding->getColorBufferHeight(); |
4426 return m_drawingBuffer->size().height(); | 4576 return m_drawingBuffer->size().height(); |
4427 } | 4577 } |
4428 | 4578 |
4429 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function
Name, GC3Denum target, bool useSixEnumsForCubeMap) | 4579 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function
Name, GC3Denum target, bool useSixEnumsForCubeMap, WebGLSharedObject::AcquireMod
e mode) |
4430 { | 4580 { |
4431 WebGLTexture* tex = 0; | 4581 WebGLTexture* tex = 0; |
4432 switch (target) { | 4582 switch (target) { |
4433 case GraphicsContext3D::TEXTURE_2D: | 4583 case GraphicsContext3D::TEXTURE_2D: |
4434 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); | 4584 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); |
4435 break; | 4585 break; |
4436 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: | 4586 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: |
4437 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: | 4587 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: |
4438 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: | 4588 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: |
4439 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: | 4589 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: |
(...skipping 11 matching lines...) Expand all Loading... |
4451 return 0; | 4601 return 0; |
4452 } | 4602 } |
4453 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); | 4603 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); |
4454 break; | 4604 break; |
4455 default: | 4605 default: |
4456 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali
d texture target"); | 4606 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali
d texture target"); |
4457 return 0; | 4607 return 0; |
4458 } | 4608 } |
4459 if (!tex) | 4609 if (!tex) |
4460 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n
o texture"); | 4610 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n
o texture"); |
| 4611 switch (mode) { |
| 4612 case WebGLSharedObject::ReadOnly: |
| 4613 if (!isAcquiredForReading(functionName, tex)) { |
| 4614 return 0; |
| 4615 } |
| 4616 break; |
| 4617 case WebGLSharedObject::Exclusive: |
| 4618 if (!isAcquiredForModification(functionName, tex)) { |
| 4619 return 0; |
| 4620 } |
| 4621 break; |
| 4622 default: |
| 4623 notImplemented(); |
| 4624 break; |
| 4625 } |
4461 return tex; | 4626 return tex; |
4462 } | 4627 } |
4463 | 4628 |
4464 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con
st String& string) | 4629 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con
st String& string) |
4465 { | 4630 { |
4466 const unsigned maxWebGLLocationLength = 256; | 4631 const unsigned maxWebGLLocationLength = 256; |
4467 if (string.length() > maxWebGLLocationLength) { | 4632 if (string.length() > maxWebGLLocationLength) { |
4468 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat
ion length > 256"); | 4633 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat
ion length > 256"); |
4469 return false; | 4634 return false; |
4470 } | 4635 } |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5084 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans
pose not FALSE"); | 5249 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans
pose not FALSE"); |
5085 return false; | 5250 return false; |
5086 } | 5251 } |
5087 if (size < requiredMinSize || (size % requiredMinSize)) { | 5252 if (size < requiredMinSize || (size % requiredMinSize)) { |
5088 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval
id size"); | 5253 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval
id size"); |
5089 return false; | 5254 return false; |
5090 } | 5255 } |
5091 return true; | 5256 return true; |
5092 } | 5257 } |
5093 | 5258 |
5094 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun
ctionName, GC3Denum target, GC3Denum usage) | 5259 WebGLBuffer* WebGLRenderingContext::getBufferForTarget(const char* functionName,
GC3Denum target) |
5095 { | 5260 { |
5096 WebGLBuffer* buffer = 0; | 5261 WebGLBuffer* buffer = 0; |
5097 switch (target) { | 5262 switch (target) { |
5098 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER: | 5263 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER: |
5099 buffer = m_boundVertexArrayObject->getElementArrayBuffer().get(); | 5264 buffer = m_boundVertexArrayObject->getElementArrayBuffer().get(); |
5100 break; | 5265 break; |
5101 case GraphicsContext3D::ARRAY_BUFFER: | 5266 case GraphicsContext3D::ARRAY_BUFFER: |
5102 buffer = m_boundArrayBuffer.get(); | 5267 buffer = m_boundArrayBuffer.get(); |
5103 break; | 5268 break; |
5104 default: | 5269 default: |
5105 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali
d target"); | 5270 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali
d target"); |
5106 return 0; | 5271 return 0; |
5107 } | 5272 } |
5108 if (!buffer) { | 5273 if (!buffer) { |
5109 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n
o buffer"); | 5274 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n
o buffer"); |
5110 return 0; | 5275 return 0; |
5111 } | 5276 } |
| 5277 return buffer; |
| 5278 } |
| 5279 |
| 5280 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun
ctionName, GC3Denum target, GC3Denum usage) |
| 5281 { |
| 5282 WebGLBuffer* buffer = getBufferForTarget(functionName, target); |
| 5283 if (!buffer) { |
| 5284 return 0; |
| 5285 } |
| 5286 |
| 5287 if (!isAcquiredForModification(functionName, buffer)) |
| 5288 return 0; |
5112 switch (usage) { | 5289 switch (usage) { |
5113 case GraphicsContext3D::STREAM_DRAW: | 5290 case GraphicsContext3D::STREAM_DRAW: |
5114 case GraphicsContext3D::STATIC_DRAW: | 5291 case GraphicsContext3D::STATIC_DRAW: |
5115 case GraphicsContext3D::DYNAMIC_DRAW: | 5292 case GraphicsContext3D::DYNAMIC_DRAW: |
5116 return buffer; | 5293 return buffer; |
5117 } | 5294 } |
5118 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us
age"); | 5295 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us
age"); |
5119 return 0; | 5296 return 0; |
5120 } | 5297 } |
5121 | 5298 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5180 markContextChanged(); | 5357 markContextChanged(); |
5181 return false; | 5358 return false; |
5182 } | 5359 } |
5183 | 5360 |
5184 if (!validateRenderingState()) { | 5361 if (!validateRenderingState()) { |
5185 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a
ttribs not setup correctly"); | 5362 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a
ttribs not setup correctly"); |
5186 return false; | 5363 return false; |
5187 } | 5364 } |
5188 | 5365 |
5189 const char* reason = "framebuffer incomplete"; | 5366 const char* reason = "framebuffer incomplete"; |
5190 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 5367 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare
dObject::Exclusive, &reason)) { |
5191 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func
tionName, reason); | 5368 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func
tionName, reason); |
5192 return false; | 5369 return false; |
5193 } | 5370 } |
5194 | 5371 |
5195 return true; | 5372 return true; |
5196 } | 5373 } |
5197 | 5374 |
5198 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De
num mode, GC3Dsizei count, GC3Denum type, long long offset) | 5375 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De
num mode, GC3Dsizei count, GC3Denum type, long long offset) |
5199 { | 5376 { |
5200 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5377 if (isContextLost() || !validateDrawMode(functionName, mode)) |
(...skipping 30 matching lines...) Expand all Loading... |
5231 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n
o ELEMENT_ARRAY_BUFFER bound"); | 5408 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n
o ELEMENT_ARRAY_BUFFER bound"); |
5232 return false; | 5409 return false; |
5233 } | 5410 } |
5234 | 5411 |
5235 if (!validateRenderingState()) { | 5412 if (!validateRenderingState()) { |
5236 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a
ttribs not setup correctly"); | 5413 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a
ttribs not setup correctly"); |
5237 return false; | 5414 return false; |
5238 } | 5415 } |
5239 | 5416 |
5240 const char* reason = "framebuffer incomplete"; | 5417 const char* reason = "framebuffer incomplete"; |
5241 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 5418 if (m_framebufferBinding && !m_framebufferBinding->onAccess(this, WebGLShare
dObject::Exclusive, &reason)) { |
5242 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func
tionName, reason); | 5419 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func
tionName, reason); |
5243 return false; | 5420 return false; |
5244 } | 5421 } |
5245 | 5422 |
5246 return true; | 5423 return true; |
5247 } | 5424 } |
5248 | 5425 |
5249 // Helper function to validate draw*Instanced calls | 5426 // Helper function to validate draw*Instanced calls |
5250 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D
sizei primcount) | 5427 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D
sizei primcount) |
5251 { | 5428 { |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5576 | 5753 |
5577 void WebGLRenderingContext::multisamplingChanged(bool enabled) | 5754 void WebGLRenderingContext::multisamplingChanged(bool enabled) |
5578 { | 5755 { |
5579 if (m_multisamplingAllowed != enabled) { | 5756 if (m_multisamplingAllowed != enabled) { |
5580 m_multisamplingAllowed = enabled; | 5757 m_multisamplingAllowed = enabled; |
5581 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext)
; | 5758 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext)
; |
5582 } | 5759 } |
5583 } | 5760 } |
5584 | 5761 |
5585 } // namespace WebCore | 5762 } // namespace WebCore |
OLD | NEW |