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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void WebGLObject::detach() | 65 void WebGLObject::detach() |
66 { | 66 { |
67 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. | 67 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. |
68 } | 68 } |
69 | 69 |
70 void WebGLObject::detachAndDeleteObject() | 70 void WebGLObject::detachAndDeleteObject() |
71 { | 71 { |
72 // To ensure that all platform objects are deleted after being detached, | 72 // Helper method that pairs detachment with platform object |
73 // this method does them together. | 73 // deletion. |
74 // | 74 // |
75 // The individual WebGL destructors need to call detachAndDeleteObject() | 75 // With Oilpan enabled, objects may end up being finalized without |
76 // rather than do it based on Oilpan GC. | 76 // having been detached first. Consequently, the objects force |
| 77 // detachment first before deleting the platform object. Without |
| 78 // Oilpan, the objects will have been detached from the 'parent' |
| 79 // objects first and do not separately require it when finalizing. |
| 80 // |
| 81 // However, as detach() is trivial, the individual WebGL |
| 82 // destructors will always call detachAndDeleteObject() rather |
| 83 // than do it based on Oilpan being enabled. |
77 detach(); | 84 detach(); |
78 deleteObject(nullptr); | 85 deleteObject(nullptr); |
79 } | 86 } |
80 | 87 |
81 void WebGLObject::onDetached(WebGraphicsContext3D* context3d) | 88 void WebGLObject::onDetached(WebGraphicsContext3D* context3d) |
82 { | 89 { |
83 if (m_attachmentCount) | 90 if (m_attachmentCount) |
84 --m_attachmentCount; | 91 --m_attachmentCount; |
85 if (m_deleted) | 92 if (m_deleted) |
86 deleteObject(context3d); | 93 deleteObject(context3d); |
87 } | 94 } |
88 | 95 |
89 } // namespace blink | 96 } // namespace blink |
OLD | NEW |