Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "core/html/canvas/WebGLObject.h" | 28 #include "core/html/canvas/WebGLObject.h" |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 WebGLObject::WebGLObject(WebGLRenderingContextBase*) | 32 WebGLObject::WebGLObject(WebGLRenderingContextBase* base) |
|
haraken
2014/07/22 03:46:10
|base| is not needed.
sof
2014/07/22 06:15:21
Removed.
| |
| 33 : m_object(0) | 33 : m_object(0) |
| 34 , m_attachmentCount(0) | 34 , m_attachmentCount(0) |
| 35 , m_deleted(false) | 35 , m_deleted(false) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 WebGLObject::~WebGLObject() | 39 WebGLObject::~WebGLObject() |
| 40 { | 40 { |
| 41 #if ENABLE(OILPAN) | |
|
haraken
2014/07/22 03:46:10
Do we need #if ENABLE(OILPAN)? I guess ASSERT(m_de
sof
2014/07/22 06:15:21
I made it condition to avoid needlessly upsetting
| |
| 42 // Verify that platform objects have been explicitly deleted. | |
| 43 ASSERT(m_deleted); | |
| 44 #endif | |
| 41 } | 45 } |
| 42 | 46 |
| 43 void WebGLObject::setObject(Platform3DObject object) | 47 void WebGLObject::setObject(Platform3DObject object) |
| 44 { | 48 { |
| 45 // object==0 && m_deleted==false indicating an uninitialized state; | 49 // object==0 && m_deleted==false indicating an uninitialized state; |
| 46 ASSERT(!m_object && !m_deleted); | 50 ASSERT(!m_object && !m_deleted); |
| 47 m_object = object; | 51 m_object = object; |
| 48 } | 52 } |
| 49 | 53 |
| 50 void WebGLObject::deleteObject(blink::WebGraphicsContext3D* context3d) | 54 void WebGLObject::deleteObject(blink::WebGraphicsContext3D* context3d) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 63 if (context3d) | 67 if (context3d) |
| 64 deleteObjectImpl(context3d, m_object); | 68 deleteObjectImpl(context3d, m_object); |
| 65 | 69 |
| 66 m_object = 0; | 70 m_object = 0; |
| 67 } | 71 } |
| 68 } | 72 } |
| 69 | 73 |
| 70 void WebGLObject::detach() | 74 void WebGLObject::detach() |
| 71 { | 75 { |
| 72 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. | 76 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. |
| 73 } | 77 } |
| 74 | 78 |
| 79 void WebGLObject::detachAndDeleteObject() | |
| 80 { | |
| 81 // Helper method that pairs detachment with platform object | |
| 82 // deletion. | |
| 83 // | |
| 84 // With Oilpan enabled, objects may end up being finalized without | |
| 85 // having been detached first. Consequently, the objects force | |
| 86 // detachment first before deleting the platform object. Without | |
| 87 // Oilpan, the objects will have been detached from the 'parent' | |
| 88 // objects first and do not separately require it when finalizing. | |
| 89 // | |
| 90 // However, as detach() is trivial, the individual WebGL | |
| 91 // destructors will always call detachAndDeleteObject() rather | |
| 92 // than do it based on Oilpan being enabled. | |
| 93 detach(); | |
| 94 deleteObject(0); | |
| 95 } | |
| 75 | 96 |
| 76 void WebGLObject::onDetached(blink::WebGraphicsContext3D* context3d) | 97 void WebGLObject::onDetached(blink::WebGraphicsContext3D* context3d) |
| 77 { | 98 { |
| 78 if (m_attachmentCount) | 99 if (m_attachmentCount) |
| 79 --m_attachmentCount; | 100 --m_attachmentCount; |
| 80 if (m_deleted) | 101 if (m_deleted) |
|
haraken
2014/07/22 03:46:10
Probably not related to this CL, but why isn't thi
| |
| 81 deleteObject(context3d); | 102 deleteObject(context3d); |
| 82 } | 103 } |
| 83 | 104 |
| 84 } | 105 } |
| OLD | NEW |