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 PassRefPtrWillBeRawPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContextB ase* ctx) | 35 WebGLProgram* WebGLProgram::create(WebGLRenderingContextBase* ctx) |
36 { | 36 { |
37 return adoptRefWillBeNoop(new WebGLProgram(ctx)); | 37 return 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) | |
52 // These heap objects handle detachment on their own. Clear out | |
53 // the references to prevent deleteObjectImpl() from trying to do | |
54 // same, as we cannot safely access other heap objects from this | |
55 // destructor. | |
56 m_vertexShader = nullptr; | |
57 m_fragmentShader = nullptr; | |
haraken
2015/08/04 00:06:52
You shouldn't remove this. This code is necessary
peria
2015/08/04 09:10:25
Done.
I did not notice they are touched in detachA
| |
58 #endif | |
59 // Always call detach here to ensure that platform object deletion | 51 // Always call detach here to ensure that platform object deletion |
60 // happens with Oilpan enabled. It keeps the code regular to do it | 52 // happens with Oilpan enabled. It keeps the code regular to do it |
61 // with or without Oilpan enabled. | 53 // with or without Oilpan enabled. |
62 // | 54 // |
63 // See comment in WebGLBuffer's destructor for additional | 55 // See comment in WebGLBuffer's destructor for additional |
64 // information on why this is done for WebGLSharedObject-derived | 56 // information on why this is done for WebGLSharedObject-derived |
65 // objects. | 57 // objects. |
66 detachAndDeleteObject(); | 58 detachAndDeleteObject(); |
67 } | 59 } |
68 | 60 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 void WebGLProgram::increaseLinkCount() | 105 void WebGLProgram::increaseLinkCount() |
114 { | 106 { |
115 ++m_linkCount; | 107 ++m_linkCount; |
116 m_infoValid = false; | 108 m_infoValid = false; |
117 } | 109 } |
118 | 110 |
119 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) | 111 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) |
120 { | 112 { |
121 switch (type) { | 113 switch (type) { |
122 case GL_VERTEX_SHADER: | 114 case GL_VERTEX_SHADER: |
123 return m_vertexShader.get(); | 115 return m_vertexShader; |
124 case GL_FRAGMENT_SHADER: | 116 case GL_FRAGMENT_SHADER: |
125 return m_fragmentShader.get(); | 117 return m_fragmentShader; |
126 default: | 118 default: |
127 return 0; | 119 return 0; |
128 } | 120 } |
129 } | 121 } |
130 | 122 |
131 bool WebGLProgram::attachShader(WebGLShader* shader) | 123 bool WebGLProgram::attachShader(WebGLShader* shader) |
132 { | 124 { |
133 if (!shader || !shader->object()) | 125 if (!shader || !shader->object()) |
134 return false; | 126 return false; |
135 switch (shader->type()) { | 127 switch (shader->type()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 } | 196 } |
205 | 197 |
206 DEFINE_TRACE(WebGLProgram) | 198 DEFINE_TRACE(WebGLProgram) |
207 { | 199 { |
208 visitor->trace(m_vertexShader); | 200 visitor->trace(m_vertexShader); |
209 visitor->trace(m_fragmentShader); | 201 visitor->trace(m_fragmentShader); |
210 WebGLSharedPlatform3DObject::trace(visitor); | 202 WebGLSharedPlatform3DObject::trace(visitor); |
211 } | 203 } |
212 | 204 |
213 } // namespace blink | 205 } // namespace blink |
OLD | NEW |