Chromium Code Reviews| 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) | 51 #if ENABLE(OILPAN) |
|
haraken
2015/08/05 04:12:19
You need to drop "#if ENABLE(OILPAN)", because m_v
peria
2015/08/06 05:47:00
Done.
| |
| 52 // These heap objects handle detachment on their own. Clear out | 52 // These heap objects handle detachment on their own. Clear out |
| 53 // the references to prevent deleteObjectImpl() from trying to do | 53 // the references to prevent deleteObjectImpl() from trying to do |
| 54 // same, as we cannot safely access other heap objects from this | 54 // same, as we cannot safely access other heap objects from this |
| 55 // destructor. | 55 // destructor. |
| 56 m_vertexShader = nullptr; | 56 m_vertexShader = nullptr; |
| 57 m_fragmentShader = nullptr; | 57 m_fragmentShader = nullptr; |
| 58 #endif | 58 #endif |
| 59 // Always call detach here to ensure that platform object deletion | 59 |
| 60 // happens with Oilpan enabled. It keeps the code regular to do it | 60 // Call detach here to ensure that platform object deletion happens. |
| 61 // with or without Oilpan enabled. | |
| 62 // | 61 // |
| 63 // See comment in WebGLBuffer's destructor for additional | 62 // See comment in WebGLBuffer's destructor for additional |
| 64 // information on why this is done for WebGLSharedObject-derived | 63 // information on why this is done for WebGLSharedObject-derived |
| 65 // objects. | 64 // objects. |
| 66 detachAndDeleteObject(); | 65 detachAndDeleteObject(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) | 68 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) |
| 70 { | 69 { |
| 71 context3d->deleteProgram(m_object); | 70 context3d->deleteProgram(m_object); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 void WebGLProgram::increaseLinkCount() | 112 void WebGLProgram::increaseLinkCount() |
| 114 { | 113 { |
| 115 ++m_linkCount; | 114 ++m_linkCount; |
| 116 m_infoValid = false; | 115 m_infoValid = false; |
| 117 } | 116 } |
| 118 | 117 |
| 119 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) | 118 WebGLShader* WebGLProgram::getAttachedShader(GLenum type) |
| 120 { | 119 { |
| 121 switch (type) { | 120 switch (type) { |
| 122 case GL_VERTEX_SHADER: | 121 case GL_VERTEX_SHADER: |
| 123 return m_vertexShader.get(); | 122 return m_vertexShader; |
| 124 case GL_FRAGMENT_SHADER: | 123 case GL_FRAGMENT_SHADER: |
| 125 return m_fragmentShader.get(); | 124 return m_fragmentShader; |
| 126 default: | 125 default: |
| 127 return 0; | 126 return 0; |
| 128 } | 127 } |
| 129 } | 128 } |
| 130 | 129 |
| 131 bool WebGLProgram::attachShader(WebGLShader* shader) | 130 bool WebGLProgram::attachShader(WebGLShader* shader) |
| 132 { | 131 { |
| 133 if (!shader || !shader->object()) | 132 if (!shader || !shader->object()) |
| 134 return false; | 133 return false; |
| 135 switch (shader->type()) { | 134 switch (shader->type()) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 } | 203 } |
| 205 | 204 |
| 206 DEFINE_TRACE(WebGLProgram) | 205 DEFINE_TRACE(WebGLProgram) |
| 207 { | 206 { |
| 208 visitor->trace(m_vertexShader); | 207 visitor->trace(m_vertexShader); |
| 209 visitor->trace(m_fragmentShader); | 208 visitor->trace(m_fragmentShader); |
| 210 WebGLSharedPlatform3DObject::trace(visitor); | 209 WebGLSharedPlatform3DObject::trace(visitor); |
| 211 } | 210 } |
| 212 | 211 |
| 213 } // namespace blink | 212 } // namespace blink |
| OLD | NEW |