12bde8e466a4451c7319e3a072d118917957d6554Steve Block/* 22bde8e466a4451c7319e3a072d118917957d6554Steve Block * Copyright (C) 2011 Google Inc. All rights reserved. 32bde8e466a4451c7319e3a072d118917957d6554Steve Block * 42bde8e466a4451c7319e3a072d118917957d6554Steve Block * Redistribution and use in source and binary forms, with or without 52bde8e466a4451c7319e3a072d118917957d6554Steve Block * modification, are permitted provided that the following conditions 62bde8e466a4451c7319e3a072d118917957d6554Steve Block * are met: 72bde8e466a4451c7319e3a072d118917957d6554Steve Block * 82bde8e466a4451c7319e3a072d118917957d6554Steve Block * 1. Redistributions of source code must retain the above copyright 92bde8e466a4451c7319e3a072d118917957d6554Steve Block * notice, this list of conditions and the following disclaimer. 102bde8e466a4451c7319e3a072d118917957d6554Steve Block * 2. Redistributions in binary form must reproduce the above copyright 112bde8e466a4451c7319e3a072d118917957d6554Steve Block * notice, this list of conditions and the following disclaimer in the 122bde8e466a4451c7319e3a072d118917957d6554Steve Block * documentation and/or other materials provided with the distribution. 132bde8e466a4451c7319e3a072d118917957d6554Steve Block * 142bde8e466a4451c7319e3a072d118917957d6554Steve Block * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 152bde8e466a4451c7319e3a072d118917957d6554Steve Block * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 162bde8e466a4451c7319e3a072d118917957d6554Steve Block * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 172bde8e466a4451c7319e3a072d118917957d6554Steve Block * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 182bde8e466a4451c7319e3a072d118917957d6554Steve Block * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 192bde8e466a4451c7319e3a072d118917957d6554Steve Block * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 202bde8e466a4451c7319e3a072d118917957d6554Steve Block * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 212bde8e466a4451c7319e3a072d118917957d6554Steve Block * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 222bde8e466a4451c7319e3a072d118917957d6554Steve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 232bde8e466a4451c7319e3a072d118917957d6554Steve Block * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 242bde8e466a4451c7319e3a072d118917957d6554Steve Block */ 252bde8e466a4451c7319e3a072d118917957d6554Steve Block 262bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "config.h" 272bde8e466a4451c7319e3a072d118917957d6554Steve Block 282bde8e466a4451c7319e3a072d118917957d6554Steve Block#if USE(ACCELERATED_COMPOSITING) 292bde8e466a4451c7319e3a072d118917957d6554Steve Block 302bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "cc/CCPluginLayerImpl.h" 312bde8e466a4451c7319e3a072d118917957d6554Steve Block 322bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "GraphicsContext3D.h" 332bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "LayerRendererChromium.h" 342bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "PluginLayerChromium.h" 352bde8e466a4451c7319e3a072d118917957d6554Steve Block#include <wtf/text/WTFString.h> 362bde8e466a4451c7319e3a072d118917957d6554Steve Block 372bde8e466a4451c7319e3a072d118917957d6554Steve Blocknamespace WebCore { 382bde8e466a4451c7319e3a072d118917957d6554Steve Block 392bde8e466a4451c7319e3a072d118917957d6554Steve BlockCCPluginLayerImpl::CCPluginLayerImpl(LayerChromium* owner) 402bde8e466a4451c7319e3a072d118917957d6554Steve Block : CCLayerImpl(owner) 412bde8e466a4451c7319e3a072d118917957d6554Steve Block , m_textureId(0) 422bde8e466a4451c7319e3a072d118917957d6554Steve Block{ 432bde8e466a4451c7319e3a072d118917957d6554Steve Block} 442bde8e466a4451c7319e3a072d118917957d6554Steve Block 452bde8e466a4451c7319e3a072d118917957d6554Steve BlockCCPluginLayerImpl::~CCPluginLayerImpl() 462bde8e466a4451c7319e3a072d118917957d6554Steve Block{ 472bde8e466a4451c7319e3a072d118917957d6554Steve Block} 482bde8e466a4451c7319e3a072d118917957d6554Steve Block 492daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdochvoid CCPluginLayerImpl::draw(const IntRect&) 502bde8e466a4451c7319e3a072d118917957d6554Steve Block{ 512bde8e466a4451c7319e3a072d118917957d6554Steve Block ASSERT(layerRenderer()); 522bde8e466a4451c7319e3a072d118917957d6554Steve Block const CCPluginLayerImpl::Program* program = layerRenderer()->pluginLayerProgram(); 532bde8e466a4451c7319e3a072d118917957d6554Steve Block ASSERT(program && program->initialized()); 542bde8e466a4451c7319e3a072d118917957d6554Steve Block GraphicsContext3D* context = layerRenderer()->context(); 552bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); 562bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId)); 572bde8e466a4451c7319e3a072d118917957d6554Steve Block 582bde8e466a4451c7319e3a072d118917957d6554Steve Block // FIXME: setting the texture parameters every time is redundant. Move this code somewhere 592bde8e466a4451c7319e3a072d118917957d6554Steve Block // where it will only happen once per texture. 602bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); 612bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); 622bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); 632bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); 642bde8e466a4451c7319e3a072d118917957d6554Steve Block 652bde8e466a4451c7319e3a072d118917957d6554Steve Block layerRenderer()->useShader(program->program()); 662bde8e466a4451c7319e3a072d118917957d6554Steve Block GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 672bde8e466a4451c7319e3a072d118917957d6554Steve Block LayerChromium::drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(), 682bde8e466a4451c7319e3a072d118917957d6554Steve Block bounds().width(), bounds().height(), drawOpacity(), 692bde8e466a4451c7319e3a072d118917957d6554Steve Block program->vertexShader().matrixLocation(), 702bde8e466a4451c7319e3a072d118917957d6554Steve Block program->fragmentShader().alphaLocation()); 712bde8e466a4451c7319e3a072d118917957d6554Steve Block} 722bde8e466a4451c7319e3a072d118917957d6554Steve Block 732bde8e466a4451c7319e3a072d118917957d6554Steve Block 742bde8e466a4451c7319e3a072d118917957d6554Steve Blockvoid CCPluginLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const 752bde8e466a4451c7319e3a072d118917957d6554Steve Block{ 762bde8e466a4451c7319e3a072d118917957d6554Steve Block writeIndent(ts, indent); 772bde8e466a4451c7319e3a072d118917957d6554Steve Block ts << "plugin layer texture id: " << m_textureId << "\n"; 782bde8e466a4451c7319e3a072d118917957d6554Steve Block CCLayerImpl::dumpLayerProperties(ts, indent); 792bde8e466a4451c7319e3a072d118917957d6554Steve Block} 802bde8e466a4451c7319e3a072d118917957d6554Steve Block 812bde8e466a4451c7319e3a072d118917957d6554Steve Block} 822bde8e466a4451c7319e3a072d118917957d6554Steve Block 832bde8e466a4451c7319e3a072d118917957d6554Steve Block#endif // USE(ACCELERATED_COMPOSITING) 84