diff options
Diffstat (limited to 'Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp | 68 |
1 files changed, 9 insertions, 59 deletions
diff --git a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp index 878c142..5d595ad 100644 --- a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp @@ -29,64 +29,13 @@ #include "PluginLayerChromium.h" +#include "cc/CCLayerImpl.h" #include "GraphicsContext3D.h" #include "LayerRendererChromium.h" #include <GLES2/gl2.h> namespace WebCore { -PluginLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context) - : m_context(context) - , m_shaderProgram(0) - , m_shaderSamplerLocation(-1) - , m_shaderMatrixLocation(-1) - , m_shaderAlphaLocation(-1) - , m_initialized(false) -{ - char vertexShaderString[] = - "attribute vec4 a_position; \n" - "attribute vec2 a_texCoord; \n" - "uniform mat4 matrix; \n" - "varying vec2 v_texCoord; \n" - "void main() \n" - "{ \n" - " gl_Position = matrix * a_position; \n" - " v_texCoord = a_texCoord; \n" - "} \n"; - - char fragmentShaderString[] = - "precision mediump float; \n" - "varying vec2 v_texCoord; \n" - "uniform sampler2D s_texture; \n" - "uniform float alpha; \n" - "void main() \n" - "{ \n" - " vec4 texColor = texture2D(s_texture, vec2(v_texCoord.x, v_texCoord.y)); \n" - " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha; \n" - "} \n"; - - m_shaderProgram = createShaderProgram(m_context, vertexShaderString, fragmentShaderString); - if (!m_shaderProgram) { - LOG_ERROR("PluginLayerChromium: Failed to create shader program"); - return; - } - - m_shaderSamplerLocation = m_context->getUniformLocation(m_shaderProgram, "s_texture"); - m_shaderMatrixLocation = m_context->getUniformLocation(m_shaderProgram, "matrix"); - m_shaderAlphaLocation = m_context->getUniformLocation(m_shaderProgram, "alpha"); - ASSERT(m_shaderSamplerLocation != -1); - ASSERT(m_shaderMatrixLocation != -1); - ASSERT(m_shaderAlphaLocation != -1); - - m_initialized = true; -} - -PluginLayerChromium::SharedValues::~SharedValues() -{ - if (m_shaderProgram) - GLC(m_context, m_context->deleteProgram(m_shaderProgram)); -} - PassRefPtr<PluginLayerChromium> PluginLayerChromium::create(GraphicsLayerChromium* owner) { return adoptRef(new PluginLayerChromium(owner)); @@ -109,8 +58,8 @@ void PluginLayerChromium::updateContentsIfDirty() void PluginLayerChromium::draw() { ASSERT(layerRenderer()); - const PluginLayerChromium::SharedValues* sv = layerRenderer()->pluginLayerSharedValues(); - ASSERT(sv && sv->initialized()); + const PluginLayerChromium::Program* program = layerRenderer()->pluginLayerProgram(); + ASSERT(program && program->initialized()); GraphicsContext3D* context = layerRendererContext(); GLC(context, context->activeTexture(GL_TEXTURE0)); GLC(context, context->bindTexture(GL_TEXTURE_2D, m_textureId)); @@ -122,11 +71,12 @@ void PluginLayerChromium::draw() GLC(context, context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); GLC(context, context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); - layerRenderer()->useShader(sv->shaderProgram()); - GLC(context, context->uniform1i(sv->shaderSamplerLocation(), 0)); - drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(), - bounds().width(), bounds().height(), drawOpacity(), - sv->shaderMatrixLocation(), sv->shaderAlphaLocation()); + layerRenderer()->useShader(program->program()); + GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); + drawTexturedQuad(context, layerRenderer()->projectionMatrix(), ccLayerImpl()->drawTransform(), + bounds().width(), bounds().height(), ccLayerImpl()->drawOpacity(), + program->vertexShader().matrixLocation(), + program->fragmentShader().alphaLocation()); } } |