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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 willDestroyContext(this); | 763 willDestroyContext(this); |
764 } | 764 } |
765 | 765 |
766 void WebGLRenderingContextBase::destroyContext() | 766 void WebGLRenderingContextBase::destroyContext() |
767 { | 767 { |
768 if (!drawingBuffer()) | 768 if (!drawingBuffer()) |
769 return; | 769 return; |
770 | 770 |
771 m_extensionsUtil.clear(); | 771 m_extensionsUtil.clear(); |
772 | 772 |
773 webContext()->setContextLostCallback(0); | 773 webContext()->setContextLostCallback(nullptr); |
774 webContext()->setErrorMessageCallback(0); | 774 webContext()->setErrorMessageCallback(nullptr); |
775 | 775 |
776 ASSERT(drawingBuffer()); | 776 ASSERT(drawingBuffer()); |
777 #if ENABLE(OILPAN) | 777 #if ENABLE(OILPAN) |
778 // The DrawingBuffer ref pointers are cleared, but the | 778 // The DrawingBuffer ref pointers are cleared, but the |
779 // WebGLSharedWebGraphicsContext3D object will hold onto the | 779 // WebGLSharedWebGraphicsContext3D object will hold onto the |
780 // DrawingBuffer for as long as needed (== until all | 780 // DrawingBuffer for as long as needed (== until all |
781 // context objects have been finalized), at which point | 781 // context objects have been finalized), at which point |
782 // DrawingBuffer destruction happens. | 782 // DrawingBuffer destruction happens. |
783 m_sharedWebGraphicsContext3D.clear(); | 783 m_sharedWebGraphicsContext3D.clear(); |
784 #else | 784 #else |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 if (isContextLost()) | 1584 if (isContextLost()) |
1585 return nullptr; | 1585 return nullptr; |
1586 RefPtrWillBeRawPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); | 1586 RefPtrWillBeRawPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); |
1587 addSharedObject(o.get()); | 1587 addSharedObject(o.get()); |
1588 return o.release(); | 1588 return o.release(); |
1589 } | 1589 } |
1590 | 1590 |
1591 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum
target, WebGLRenderbuffer* renderbuffer) | 1591 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum
target, WebGLRenderbuffer* renderbuffer) |
1592 { | 1592 { |
1593 if (isContextLost()) | 1593 if (isContextLost()) |
1594 return 0; | 1594 return nullptr; |
1595 if (!renderbuffer->emulatedStencilBuffer()) { | 1595 if (!renderbuffer->emulatedStencilBuffer()) { |
1596 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1596 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
1597 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat
edStencilBuffer())); | 1597 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat
edStencilBuffer())); |
1598 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin
g.get())); | 1598 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin
g.get())); |
1599 } | 1599 } |
1600 return renderbuffer->emulatedStencilBuffer(); | 1600 return renderbuffer->emulatedStencilBuffer(); |
1601 } | 1601 } |
1602 | 1602 |
1603 PassRefPtrWillBeRawPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLen
um type) | 1603 PassRefPtrWillBeRawPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLen
um type) |
1604 { | 1604 { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 PassRefPtrWillBeRawPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUnif
orm(WebGLProgram* program, GLuint index) | 2057 PassRefPtrWillBeRawPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUnif
orm(WebGLProgram* program, GLuint index) |
2058 { | 2058 { |
2059 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 2059 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) |
2060 return nullptr; | 2060 return nullptr; |
2061 blink::WebGraphicsContext3D::ActiveInfo info; | 2061 blink::WebGraphicsContext3D::ActiveInfo info; |
2062 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) | 2062 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) |
2063 return nullptr; | 2063 return nullptr; |
2064 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2064 return WebGLActiveInfo::create(info.name, info.type, info.size); |
2065 } | 2065 } |
2066 | 2066 |
2067 Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > > WebGLRenderingCont
extBase::getAttachedShaders(WebGLProgram* program) | 2067 Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader>>> WebGLRenderingContex
tBase::getAttachedShaders(WebGLProgram* program) |
2068 { | 2068 { |
2069 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 2069 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
2070 return Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > >(); | 2070 return Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader>>>(); |
2071 | 2071 |
2072 WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > shaderObjects; | 2072 WillBeHeapVector<RefPtrWillBeMember<WebGLShader>> shaderObjects; |
2073 const GLenum shaderType[] = { | 2073 const GLenum shaderType[] = { |
2074 GL_VERTEX_SHADER, | 2074 GL_VERTEX_SHADER, |
2075 GL_FRAGMENT_SHADER | 2075 GL_FRAGMENT_SHADER |
2076 }; | 2076 }; |
2077 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GLenum); ++i) { | 2077 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GLenum); ++i) { |
2078 WebGLShader* shader = program->getAttachedShader(shaderType[i]); | 2078 WebGLShader* shader = program->getAttachedShader(shaderType[i]); |
2079 if (shader) | 2079 if (shader) |
2080 shaderObjects.append(shader); | 2080 shaderObjects.append(shader); |
2081 } | 2081 } |
2082 return shaderObjects; | 2082 return shaderObjects; |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 | 2646 |
2647 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) | 2647 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) |
2648 { | 2648 { |
2649 if (isContextLost()) | 2649 if (isContextLost()) |
2650 return String(); | 2650 return String(); |
2651 if (!validateWebGLObject("getShaderSource", shader)) | 2651 if (!validateWebGLObject("getShaderSource", shader)) |
2652 return ""; | 2652 return ""; |
2653 return ensureNotNull(shader->source()); | 2653 return ensureNotNull(shader->source()); |
2654 } | 2654 } |
2655 | 2655 |
2656 Nullable<Vector<String> > WebGLRenderingContextBase::getSupportedExtensions() | 2656 Nullable<Vector<String>> WebGLRenderingContextBase::getSupportedExtensions() |
2657 { | 2657 { |
2658 if (isContextLost()) | 2658 if (isContextLost()) |
2659 return Nullable<Vector<String> >(); | 2659 return Nullable<Vector<String>>(); |
2660 | 2660 |
2661 Vector<String> result; | 2661 Vector<String> result; |
2662 | 2662 |
2663 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2663 for (size_t i = 0; i < m_extensions.size(); ++i) { |
2664 ExtensionTracker* tracker = m_extensions[i].get(); | 2664 ExtensionTracker* tracker = m_extensions[i].get(); |
2665 if (extensionSupportedAndAllowed(tracker)) { | 2665 if (extensionSupportedAndAllowed(tracker)) { |
2666 const char* const* prefixes = tracker->prefixes(); | 2666 const char* const* prefixes = tracker->prefixes(); |
2667 for (; *prefixes; ++prefixes) { | 2667 for (; *prefixes; ++prefixes) { |
2668 String prefixedName = String(*prefixes) + tracker->extensionName
(); | 2668 String prefixedName = String(*prefixes) + tracker->extensionName
(); |
2669 result.append(prefixedName); | 2669 result.append(prefixedName); |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4365 | 4365 |
4366 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) | 4366 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) |
4367 { | 4367 { |
4368 ASSERT(!isContextLost()); | 4368 ASSERT(!isContextLost()); |
4369 m_contextObjects.add(object); | 4369 m_contextObjects.add(object); |
4370 } | 4370 } |
4371 | 4371 |
4372 void WebGLRenderingContextBase::detachAndRemoveAllObjects() | 4372 void WebGLRenderingContextBase::detachAndRemoveAllObjects() |
4373 { | 4373 { |
4374 while (m_contextObjects.size() > 0) { | 4374 while (m_contextObjects.size() > 0) { |
4375 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> >::iterator
it = m_contextObjects.begin(); | 4375 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject>>::iterator
it = m_contextObjects.begin(); |
4376 (*it)->detachContext(); | 4376 (*it)->detachContext(); |
4377 } | 4377 } |
4378 } | 4378 } |
4379 | 4379 |
4380 bool WebGLRenderingContextBase::hasPendingActivity() const | 4380 bool WebGLRenderingContextBase::hasPendingActivity() const |
4381 { | 4381 { |
4382 return false; | 4382 return false; |
4383 } | 4383 } |
4384 | 4384 |
4385 void WebGLRenderingContextBase::stop() | 4385 void WebGLRenderingContextBase::stop() |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4555 { | 4555 { |
4556 if (m_framebufferBinding && m_framebufferBinding->object()) | 4556 if (m_framebufferBinding && m_framebufferBinding->object()) |
4557 return m_framebufferBinding->colorBufferFormat(); | 4557 return m_framebufferBinding->colorBufferFormat(); |
4558 if (m_requestedAttributes->alpha()) | 4558 if (m_requestedAttributes->alpha()) |
4559 return GL_RGBA; | 4559 return GL_RGBA; |
4560 return GL_RGB; | 4560 return GL_RGB; |
4561 } | 4561 } |
4562 | 4562 |
4563 WebGLTexture* WebGLRenderingContextBase::validateTextureBinding(const char* func
tionName, GLenum target, bool useSixEnumsForCubeMap) | 4563 WebGLTexture* WebGLRenderingContextBase::validateTextureBinding(const char* func
tionName, GLenum target, bool useSixEnumsForCubeMap) |
4564 { | 4564 { |
4565 WebGLTexture* tex = 0; | 4565 WebGLTexture* tex = nullptr; |
4566 switch (target) { | 4566 switch (target) { |
4567 case GL_TEXTURE_2D: | 4567 case GL_TEXTURE_2D: |
4568 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); | 4568 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); |
4569 break; | 4569 break; |
4570 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: | 4570 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
4571 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | 4571 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
4572 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | 4572 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
4573 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | 4573 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
4574 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | 4574 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
4575 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | 4575 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
4576 if (!useSixEnumsForCubeMap) { | 4576 if (!useSixEnumsForCubeMap) { |
4577 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture ta
rget"); | 4577 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture ta
rget"); |
4578 return 0; | 4578 return nullptr; |
4579 } | 4579 } |
4580 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); | 4580 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); |
4581 break; | 4581 break; |
4582 case GL_TEXTURE_CUBE_MAP: | 4582 case GL_TEXTURE_CUBE_MAP: |
4583 if (useSixEnumsForCubeMap) { | 4583 if (useSixEnumsForCubeMap) { |
4584 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture ta
rget"); | 4584 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture ta
rget"); |
4585 return 0; | 4585 return nullptr; |
4586 } | 4586 } |
4587 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); | 4587 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); |
4588 break; | 4588 break; |
4589 default: | 4589 default: |
4590 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture target
"); | 4590 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture target
"); |
4591 return 0; | 4591 return nullptr; |
4592 } | 4592 } |
4593 if (!tex) | 4593 if (!tex) |
4594 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no texture"); | 4594 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no texture"); |
4595 return tex; | 4595 return tex; |
4596 } | 4596 } |
4597 | 4597 |
4598 bool WebGLRenderingContextBase::validateLocationLength(const char* functionName,
const String& string) | 4598 bool WebGLRenderingContextBase::validateLocationLength(const char* functionName,
const String& string) |
4599 { | 4599 { |
4600 const unsigned maxWebGLLocationLength = 256; | 4600 const unsigned maxWebGLLocationLength = 256; |
4601 if (string.length() > maxWebGLLocationLength) { | 4601 if (string.length() > maxWebGLLocationLength) { |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5275 } | 5275 } |
5276 if (size < requiredMinSize || (size % requiredMinSize)) { | 5276 if (size < requiredMinSize || (size % requiredMinSize)) { |
5277 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); | 5277 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); |
5278 return false; | 5278 return false; |
5279 } | 5279 } |
5280 return true; | 5280 return true; |
5281 } | 5281 } |
5282 | 5282 |
5283 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget(const char* fun
ctionName, GLenum target) | 5283 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget(const char* fun
ctionName, GLenum target) |
5284 { | 5284 { |
5285 WebGLBuffer* buffer = 0; | 5285 WebGLBuffer* buffer = nullptr; |
5286 switch (target) { | 5286 switch (target) { |
5287 case GL_ELEMENT_ARRAY_BUFFER: | 5287 case GL_ELEMENT_ARRAY_BUFFER: |
5288 buffer = m_boundVertexArrayObject->boundElementArrayBuffer().get(); | 5288 buffer = m_boundVertexArrayObject->boundElementArrayBuffer().get(); |
5289 break; | 5289 break; |
5290 case GL_ARRAY_BUFFER: | 5290 case GL_ARRAY_BUFFER: |
5291 buffer = m_boundArrayBuffer.get(); | 5291 buffer = m_boundArrayBuffer.get(); |
5292 break; | 5292 break; |
5293 default: | 5293 default: |
5294 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | 5294 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); |
5295 return 0; | 5295 return nullptr; |
5296 } | 5296 } |
5297 if (!buffer) { | 5297 if (!buffer) { |
5298 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no buffer"); | 5298 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no buffer"); |
5299 return 0; | 5299 return nullptr; |
5300 } | 5300 } |
5301 return buffer; | 5301 return buffer; |
5302 } | 5302 } |
5303 | 5303 |
5304 bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionNam
e, HTMLImageElement* image, ExceptionState& exceptionState) | 5304 bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionNam
e, HTMLImageElement* image, ExceptionState& exceptionState) |
5305 { | 5305 { |
5306 if (!image || !image->cachedImage()) { | 5306 if (!image || !image->cachedImage()) { |
5307 synthesizeGLError(GL_INVALID_VALUE, functionName, "no image"); | 5307 synthesizeGLError(GL_INVALID_VALUE, functionName, "no image"); |
5308 return false; | 5308 return false; |
5309 } | 5309 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5623 if (!buf) | 5623 if (!buf) |
5624 break; | 5624 break; |
5625 if (buf->size() != size) | 5625 if (buf->size() != size) |
5626 continue; | 5626 continue; |
5627 bubbleToFront(i); | 5627 bubbleToFront(i); |
5628 return buf; | 5628 return buf; |
5629 } | 5629 } |
5630 | 5630 |
5631 OwnPtr<ImageBuffer> temp(ImageBuffer::create(size)); | 5631 OwnPtr<ImageBuffer> temp(ImageBuffer::create(size)); |
5632 if (!temp) | 5632 if (!temp) |
5633 return 0; | 5633 return nullptr; |
5634 i = std::min(m_capacity - 1, i); | 5634 i = std::min(m_capacity - 1, i); |
5635 m_buffers[i] = temp.release(); | 5635 m_buffers[i] = temp.release(); |
5636 | 5636 |
5637 ImageBuffer* buf = m_buffers[i].get(); | 5637 ImageBuffer* buf = m_buffers[i].get(); |
5638 bubbleToFront(i); | 5638 bubbleToFront(i); |
5639 return buf; | 5639 return buf; |
5640 } | 5640 } |
5641 | 5641 |
5642 void WebGLRenderingContextBase::LRUImageBufferCache::bubbleToFront(int idx) | 5642 void WebGLRenderingContextBase::LRUImageBufferCache::bubbleToFront(int idx) |
5643 { | 5643 { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5821 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; | 5821 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; |
5822 } | 5822 } |
5823 #else | 5823 #else |
5824 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 5824 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
5825 { | 5825 { |
5826 return m_drawingBuffer.get(); | 5826 return m_drawingBuffer.get(); |
5827 } | 5827 } |
5828 #endif | 5828 #endif |
5829 | 5829 |
5830 } // namespace blink | 5830 } // namespace blink |
OLD | NEW |