InspectorShaderProgram.cpp [plain text]
#include "config.h"
#include "InspectorShaderProgram.h"
#include "GraphicsContext3D.h"
#include "GraphicsTypes3D.h"
#include "HTMLCanvasElement.h"
#include "InspectorCanvas.h"
#include "WebGLProgram.h"
#include "WebGLRenderingContextBase.h"
#include "WebGLShader.h"
#include <inspector/IdentifiersFactory.h>
namespace WebCore {
using namespace Inspector;
Ref<InspectorShaderProgram> InspectorShaderProgram::create(WebGLProgram& program, InspectorCanvas& inspectorCanvas)
{
return adoptRef(*new InspectorShaderProgram(program, inspectorCanvas));
}
InspectorShaderProgram::InspectorShaderProgram(WebGLProgram& program, InspectorCanvas& inspectorCanvas)
: m_identifier("program:" + IdentifiersFactory::createIdentifier())
, m_program(program)
, m_canvas(inspectorCanvas)
{
}
WebGLRenderingContextBase& InspectorShaderProgram::context() const
{
ASSERT(is<WebGLRenderingContextBase>(m_canvas.context()));
return downcast<WebGLRenderingContextBase>(m_canvas.context());
}
WebGLShader* InspectorShaderProgram::shaderForType(const String& protocolType)
{
GC3Denum shaderType;
if (protocolType == "vertex")
shaderType = GraphicsContext3D::VERTEX_SHADER;
else if (protocolType == "fragment")
shaderType = GraphicsContext3D::FRAGMENT_SHADER;
else
return nullptr;
return m_program.getAttachedShader(shaderType);
}
}