| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "modules/webgl/WebGLObject.h" | 26 #include "modules/webgl/WebGLObject.h" |
| 27 | 27 |
| 28 #include "public/platform/WebGraphicsContext3D.h" |
| 29 |
| 28 namespace blink { | 30 namespace blink { |
| 29 | 31 |
| 30 WebGLObject::WebGLObject(WebGLRenderingContextBase*) | 32 WebGLObject::WebGLObject(WebGLRenderingContextBase*) |
| 31 : m_attachmentCount(0) | 33 : m_attachmentCount(0) |
| 32 , m_deleted(false) | 34 , m_deleted(false) |
| 33 { | 35 { |
| 34 } | 36 } |
| 35 | 37 |
| 36 WebGLObject::~WebGLObject() | 38 WebGLObject::~WebGLObject() |
| 37 { | 39 { |
| 38 // Verify that platform objects have been explicitly deleted. | 40 // Verify that platform objects have been explicitly deleted. |
| 39 ASSERT(m_deleted); | 41 ASSERT(m_deleted); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void WebGLObject::deleteObject(WebGraphicsContext3D* context3d) | 44 void WebGLObject::deleteObject(WebGraphicsContext3D* context3d, gpu::gles2::GLES
2Interface* gl) |
| 43 { | 45 { |
| 44 m_deleted = true; | 46 m_deleted = true; |
| 45 if (!hasObject()) | 47 if (!hasObject()) |
| 46 return; | 48 return; |
| 47 | 49 |
| 48 if (!hasGroupOrContext()) | 50 if (!hasGroupOrContext()) |
| 49 return; | 51 return; |
| 50 | 52 |
| 51 if (!m_attachmentCount) { | 53 if (!m_attachmentCount) { |
| 52 if (!context3d) | 54 if (!context3d) { |
| 53 context3d = getAWebGraphicsContext3D(); | 55 context3d = getAWebGraphicsContext3D(); |
| 56 gl = context3d ? context3d->getGLES2Interface() : nullptr; |
| 57 } |
| 54 | 58 |
| 55 if (context3d) { | 59 if (context3d) { |
| 56 deleteObjectImpl(context3d); | 60 deleteObjectImpl(context3d, gl); |
| 57 // Ensure the inherited class no longer claims to have a valid objec
t | 61 // Ensure the inherited class no longer claims to have a valid objec
t |
| 58 ASSERT(!hasObject()); | 62 ASSERT(!hasObject()); |
| 59 } | 63 } |
| 60 } | 64 } |
| 61 } | 65 } |
| 62 | 66 |
| 63 void WebGLObject::detach() | 67 void WebGLObject::detach() |
| 64 { | 68 { |
| 65 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. | 69 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. |
| 66 } | 70 } |
| 67 | 71 |
| 68 void WebGLObject::detachAndDeleteObject() | 72 void WebGLObject::detachAndDeleteObject() |
| 69 { | 73 { |
| 70 // To ensure that all platform objects are deleted after being detached, | 74 // To ensure that all platform objects are deleted after being detached, |
| 71 // this method does them together. | 75 // this method does them together. |
| 72 // | 76 // |
| 73 // The individual WebGL destructors need to call detachAndDeleteObject() | 77 // The individual WebGL destructors need to call detachAndDeleteObject() |
| 74 // rather than do it based on Oilpan GC. | 78 // rather than do it based on Oilpan GC. |
| 75 detach(); | 79 detach(); |
| 76 deleteObject(nullptr); | 80 deleteObject(nullptr, nullptr); |
| 77 } | 81 } |
| 78 | 82 |
| 79 void WebGLObject::onDetached(WebGraphicsContext3D* context3d) | 83 void WebGLObject::onDetached(WebGraphicsContext3D* context3d, gpu::gles2::GLES2I
nterface* gl) |
| 80 { | 84 { |
| 81 if (m_attachmentCount) | 85 if (m_attachmentCount) |
| 82 --m_attachmentCount; | 86 --m_attachmentCount; |
| 83 if (m_deleted) | 87 if (m_deleted) |
| 84 deleteObject(context3d); | 88 deleteObject(context3d, gl); |
| 85 } | 89 } |
| 86 | 90 |
| 87 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |