| 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 | 51 // These heap objects handle detachment on their own. Clear out |
| 53 // the references to prevent deleteObjectImpl() from trying to do | 52 // the references to prevent deleteObjectImpl() from trying to do |
| 54 // same, as we cannot safely access other heap objects from this | 53 // same, as we cannot safely access other heap objects from this |
| 55 // destructor. | 54 // destructor. |
| 56 m_vertexShader = nullptr; | 55 m_vertexShader = nullptr; |
| 57 m_fragmentShader = nullptr; | 56 m_fragmentShader = nullptr; |
| 58 #endif | 57 |
| 59 // Always call detach here to ensure that platform object deletion | 58 // See the comment in WebGLObject::detachAndDeleteObject(). |
| 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. | |
| 66 detachAndDeleteObject(); | 59 detachAndDeleteObject(); |
| 67 } | 60 } |
| 68 | 61 |
| 69 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) | 62 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) |
| 70 { | 63 { |
| 71 context3d->deleteProgram(m_object); | 64 context3d->deleteProgram(m_object); |
| 72 m_object = 0; | 65 m_object = 0; |
| 73 if (m_vertexShader) { | 66 if (m_vertexShader) { |
| 74 m_vertexShader->onDetached(context3d); | 67 m_vertexShader->onDetached(context3d); |
| 75 m_vertexShader = nullptr; | 68 m_vertexShader = nullptr; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void WebGLProgram::increaseLinkCount() | 106 void WebGLProgram::increaseLinkCount() |
| 114 { | 107 { |
| 115 ++m_linkCount; | 108 ++m_linkCount; |
| 116 m_infoValid = false; | 109 m_infoValid = false; |
| 117 } | 110 } |
| 118 | 111 |
| 119 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) | 112 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) |
| 120 { | 113 { |
| 121 switch (type) { | 114 switch (type) { |
| 122 case GL_VERTEX_SHADER: | 115 case GL_VERTEX_SHADER: |
| 123 return m_vertexShader.get(); | 116 return m_vertexShader; |
| 124 case GL_FRAGMENT_SHADER: | 117 case GL_FRAGMENT_SHADER: |
| 125 return m_fragmentShader.get(); | 118 return m_fragmentShader; |
| 126 default: | 119 default: |
| 127 return 0; | 120 return 0; |
| 128 } | 121 } |
| 129 } | 122 } |
| 130 | 123 |
| 131 bool WebGLProgram::attachShader(WebGLShader* shader) | 124 bool WebGLProgram::attachShader(WebGLShader* shader) |
| 132 { | 125 { |
| 133 if (!shader || !shader->object()) | 126 if (!shader || !shader->object()) |
| 134 return false; | 127 return false; |
| 135 switch (shader->type()) { | 128 switch (shader->type()) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 197 } |
| 205 | 198 |
| 206 DEFINE_TRACE(WebGLProgram) | 199 DEFINE_TRACE(WebGLProgram) |
| 207 { | 200 { |
| 208 visitor->trace(m_vertexShader); | 201 visitor->trace(m_vertexShader); |
| 209 visitor->trace(m_fragmentShader); | 202 visitor->trace(m_fragmentShader); |
| 210 WebGLSharedPlatform3DObject::trace(visitor); | 203 WebGLSharedPlatform3DObject::trace(visitor); |
| 211 } | 204 } |
| 212 | 205 |
| 213 } // namespace blink | 206 } // namespace blink |
| OLD | NEW |