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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 | 27 |
28 #include "modules/webgl/WebGLProgram.h" | 28 #include "modules/webgl/WebGLProgram.h" |
29 | 29 |
30 #include "modules/webgl/WebGLContextGroup.h" | 30 #include "modules/webgl/WebGLContextGroup.h" |
31 #include "modules/webgl/WebGLRenderingContextBase.h" | 31 #include "modules/webgl/WebGLRenderingContextBase.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 WebGLProgram* WebGLProgram::create(WebGLRenderingContextBase* ctx) | 35 PassRefPtrWillBeRawPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContextB
ase* ctx) |
36 { | 36 { |
37 return new WebGLProgram(ctx); | 37 return adoptRefWillBeNoop(new WebGLProgram(ctx)); |
38 } | 38 } |
39 | 39 |
40 WebGLProgram::WebGLProgram(WebGLRenderingContextBase* ctx) | 40 WebGLProgram::WebGLProgram(WebGLRenderingContextBase* ctx) |
41 : WebGLSharedPlatform3DObject(ctx) | 41 : WebGLSharedPlatform3DObject(ctx) |
42 , m_linkStatus(false) | 42 , m_linkStatus(false) |
43 , m_linkCount(0) | 43 , m_linkCount(0) |
44 , m_infoValid(true) | 44 , m_infoValid(true) |
45 { | 45 { |
46 setObject(ctx->webContext()->createProgram()); | 46 setObject(ctx->webContext()->createProgram()); |
47 } | 47 } |
48 | 48 |
49 WebGLProgram::~WebGLProgram() | 49 WebGLProgram::~WebGLProgram() |
50 { | 50 { |
| 51 #if ENABLE(OILPAN) |
51 // These heap objects handle detachment on their own. Clear out | 52 // These heap objects handle detachment on their own. Clear out |
52 // the references to prevent deleteObjectImpl() from trying to do | 53 // the references to prevent deleteObjectImpl() from trying to do |
53 // same, as we cannot safely access other heap objects from this | 54 // same, as we cannot safely access other heap objects from this |
54 // destructor. | 55 // destructor. |
55 m_vertexShader = nullptr; | 56 m_vertexShader = nullptr; |
56 m_fragmentShader = nullptr; | 57 m_fragmentShader = nullptr; |
57 | 58 #endif |
58 // See the comment in WebGLObject::detachAndDeleteObject(). | 59 // Always call detach here to ensure that platform object deletion |
| 60 // happens with Oilpan enabled. It keeps the code regular to do it |
| 61 // with or without Oilpan enabled. |
| 62 // |
| 63 // See comment in WebGLBuffer's destructor for additional |
| 64 // information on why this is done for WebGLSharedObject-derived |
| 65 // objects. |
59 detachAndDeleteObject(); | 66 detachAndDeleteObject(); |
60 } | 67 } |
61 | 68 |
62 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) | 69 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) |
63 { | 70 { |
64 context3d->deleteProgram(m_object); | 71 context3d->deleteProgram(m_object); |
65 m_object = 0; | 72 m_object = 0; |
66 if (m_vertexShader) { | 73 if (m_vertexShader) { |
67 m_vertexShader->onDetached(context3d); | 74 m_vertexShader->onDetached(context3d); |
68 m_vertexShader = nullptr; | 75 m_vertexShader = nullptr; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void WebGLProgram::increaseLinkCount() | 113 void WebGLProgram::increaseLinkCount() |
107 { | 114 { |
108 ++m_linkCount; | 115 ++m_linkCount; |
109 m_infoValid = false; | 116 m_infoValid = false; |
110 } | 117 } |
111 | 118 |
112 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) | 119 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) |
113 { | 120 { |
114 switch (type) { | 121 switch (type) { |
115 case GL_VERTEX_SHADER: | 122 case GL_VERTEX_SHADER: |
116 return m_vertexShader; | 123 return m_vertexShader.get(); |
117 case GL_FRAGMENT_SHADER: | 124 case GL_FRAGMENT_SHADER: |
118 return m_fragmentShader; | 125 return m_fragmentShader.get(); |
119 default: | 126 default: |
120 return 0; | 127 return 0; |
121 } | 128 } |
122 } | 129 } |
123 | 130 |
124 bool WebGLProgram::attachShader(WebGLShader* shader) | 131 bool WebGLProgram::attachShader(WebGLShader* shader) |
125 { | 132 { |
126 if (!shader || !shader->object()) | 133 if (!shader || !shader->object()) |
127 return false; | 134 return false; |
128 switch (shader->type()) { | 135 switch (shader->type()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 204 } |
198 | 205 |
199 DEFINE_TRACE(WebGLProgram) | 206 DEFINE_TRACE(WebGLProgram) |
200 { | 207 { |
201 visitor->trace(m_vertexShader); | 208 visitor->trace(m_vertexShader); |
202 visitor->trace(m_fragmentShader); | 209 visitor->trace(m_fragmentShader); |
203 WebGLSharedPlatform3DObject::trace(visitor); | 210 WebGLSharedPlatform3DObject::trace(visitor); |
204 } | 211 } |
205 | 212 |
206 } // namespace blink | 213 } // namespace blink |
OLD | NEW |