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 // Helper method that pairs detachment with platform object | 72 // To ensure that all platform objects are deleted after being detached, |
73 // deletion. | 73 // this method does them together. |
74 // | 74 // |
75 // With Oilpan enabled, objects may end up being finalized without | 75 // The individual WebGL destructors need to call detachAndDeleteObject() |
76 // having been detached first. Consequently, the objects force | 76 // rather than do it based on Oilpan GC. |
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. | |
84 detach(); | 77 detach(); |
85 deleteObject(nullptr); | 78 deleteObject(nullptr); |
86 } | 79 } |
87 | 80 |
88 void WebGLObject::onDetached(WebGraphicsContext3D* context3d) | 81 void WebGLObject::onDetached(WebGraphicsContext3D* context3d) |
89 { | 82 { |
90 if (m_attachmentCount) | 83 if (m_attachmentCount) |
91 --m_attachmentCount; | 84 --m_attachmentCount; |
92 if (m_deleted) | 85 if (m_deleted) |
93 deleteObject(context3d); | 86 deleteObject(context3d); |
94 } | 87 } |
95 | 88 |
96 } // namespace blink | 89 } // namespace blink |
OLD | NEW |