• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1.  Redistributions of source code must retain the above copyright
9  *     notice, this list of conditions and the following disclaimer.
10  * 2.  Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 
28 #if USE(ACCELERATED_COMPOSITING)
29 
30 #include "cc/CCPluginLayerImpl.h"
31 
32 #include "GraphicsContext3D.h"
33 #include "LayerRendererChromium.h"
34 #include "PluginLayerChromium.h"
35 #include <wtf/text/WTFString.h>
36 
37 namespace WebCore {
38 
CCPluginLayerImpl(LayerChromium * owner)39 CCPluginLayerImpl::CCPluginLayerImpl(LayerChromium* owner)
40     : CCLayerImpl(owner)
41     , m_textureId(0)
42 {
43 }
44 
~CCPluginLayerImpl()45 CCPluginLayerImpl::~CCPluginLayerImpl()
46 {
47 }
48 
draw(const IntRect &)49 void CCPluginLayerImpl::draw(const IntRect&)
50 {
51     ASSERT(layerRenderer());
52     const CCPluginLayerImpl::Program* program = layerRenderer()->pluginLayerProgram();
53     ASSERT(program && program->initialized());
54     GraphicsContext3D* context = layerRenderer()->context();
55     GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
56     GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId));
57 
58     // FIXME: setting the texture parameters every time is redundant. Move this code somewhere
59     // where it will only happen once per texture.
60     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
61     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
62     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
63     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
64 
65     layerRenderer()->useShader(program->program());
66     GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
67     LayerChromium::drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
68                                     bounds().width(), bounds().height(), drawOpacity(),
69                                     program->vertexShader().matrixLocation(),
70                                     program->fragmentShader().alphaLocation());
71 }
72 
73 
dumpLayerProperties(TextStream & ts,int indent) const74 void CCPluginLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
75 {
76     writeIndent(ts, indent);
77     ts << "plugin layer texture id: " << m_textureId << "\n";
78     CCLayerImpl::dumpLayerProperties(ts, indent);
79 }
80 
81 }
82 
83 #endif // USE(ACCELERATED_COMPOSITING)
84