Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: Source/core/html/canvas/WebGLObject.cpp

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Smaller adjustments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 20 matching lines...) Expand all
31 31
32 WebGLObject::WebGLObject(WebGLRenderingContextBase*) 32 WebGLObject::WebGLObject(WebGLRenderingContextBase*)
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 // Verify that platform objects have been explicitly deleted.
42 ASSERT(m_deleted);
41 } 43 }
42 44
43 void WebGLObject::setObject(Platform3DObject object) 45 void WebGLObject::setObject(Platform3DObject object)
44 { 46 {
45 // object==0 && m_deleted==false indicating an uninitialized state; 47 // object==0 && m_deleted==false indicating an uninitialized state;
46 ASSERT(!m_object && !m_deleted); 48 ASSERT(!m_object && !m_deleted);
47 m_object = object; 49 m_object = object;
48 } 50 }
49 51
50 void WebGLObject::deleteObject(blink::WebGraphicsContext3D* context3d) 52 void WebGLObject::deleteObject(blink::WebGraphicsContext3D* context3d)
(...skipping 12 matching lines...) Expand all
63 if (context3d) 65 if (context3d)
64 deleteObjectImpl(context3d, m_object); 66 deleteObjectImpl(context3d, m_object);
65 67
66 m_object = 0; 68 m_object = 0;
67 } 69 }
68 } 70 }
69 71
70 void WebGLObject::detach() 72 void WebGLObject::detach()
71 { 73 {
72 m_attachmentCount = 0; // Make sure OpenGL resource is deleted. 74 m_attachmentCount = 0; // Make sure OpenGL resource is deleted.
73 } 75 }
74 76
77 void WebGLObject::detachAndDeleteObject()
78 {
79 // Helper method that pairs detachment with platform object
80 // deletion.
81 //
82 // With Oilpan enabled, objects may end up being finalized without
83 // having been detached first. Consequently, the objects force
84 // detachment first before deleting the platform object. Without
85 // Oilpan, the objects will have been detached from the 'parent'
86 // objects first and do not separately require it when finalizing.
87 //
88 // However, as detach() is trivial, the individual WebGL
89 // destructors will always call detachAndDeleteObject() rather
90 // than do it based on Oilpan being enabled.
91 detach();
92 deleteObject(0);
93 }
75 94
76 void WebGLObject::onDetached(blink::WebGraphicsContext3D* context3d) 95 void WebGLObject::onDetached(blink::WebGraphicsContext3D* context3d)
77 { 96 {
78 if (m_attachmentCount) 97 if (m_attachmentCount)
79 --m_attachmentCount; 98 --m_attachmentCount;
80 if (m_deleted) 99 if (m_deleted)
81 deleteObject(context3d); 100 deleteObject(context3d);
82 } 101 }
83 102
84 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698