~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2012 Samsung Electronics
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "config.h"
 
21
 
 
22
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
 
23
 
 
24
#include "AcceleratedCompositingContextEfl.h"
 
25
 
 
26
#include "FrameView.h"
 
27
#include "GraphicsContext3D.h"
 
28
#include "HostWindow.h"
 
29
#include "PageClientEfl.h"
 
30
#include "TextureMapperGL.h"
 
31
#include "TextureMapperLayer.h"
 
32
#include "ewk_view_private.h"
 
33
 
 
34
namespace WebCore {
 
35
 
 
36
PassOwnPtr<AcceleratedCompositingContext> AcceleratedCompositingContext::create(HostWindow* hostWindow)
 
37
{
 
38
    OwnPtr<AcceleratedCompositingContext> context = adoptPtr(new AcceleratedCompositingContext);
 
39
    if (!context->initialize(hostWindow))
 
40
        return nullptr;
 
41
 
 
42
    return context.release();
 
43
}
 
44
 
 
45
AcceleratedCompositingContext::AcceleratedCompositingContext()
 
46
    : m_view(0)
 
47
    , m_rootTextureMapperLayer(0)
 
48
{
 
49
}
 
50
 
 
51
AcceleratedCompositingContext::~AcceleratedCompositingContext()
 
52
{
 
53
}
 
54
 
 
55
bool AcceleratedCompositingContext::initialize(HostWindow* hostWindow)
 
56
{
 
57
    m_view = hostWindow->platformPageClient()->view();
 
58
    if (!m_view)
 
59
        return false;
 
60
 
 
61
    m_context3D = GraphicsContext3D::create(GraphicsContext3D::Attributes(), hostWindow, WebCore::GraphicsContext3D::RenderDirectlyToHostWindow);
 
62
    if (!m_context3D)
 
63
        return false;
 
64
 
 
65
    return true;
 
66
}
 
67
 
 
68
void AcceleratedCompositingContext::syncLayersNow()
 
69
{
 
70
    if (m_rootGraphicsLayer)
 
71
        m_rootGraphicsLayer->flushCompositingStateForThisLayerOnly();
 
72
 
 
73
    EWKPrivate::corePage(m_view)->mainFrame()->view()->flushCompositingStateIncludingSubframes();
 
74
}
 
75
 
 
76
void AcceleratedCompositingContext::renderLayers()
 
77
{
 
78
    if (!m_rootGraphicsLayer)
 
79
        return;
 
80
 
 
81
    if (!m_context3D->makeContextCurrent())
 
82
        return;
 
83
 
 
84
    int width = 0;
 
85
    int height = 0;
 
86
    evas_object_geometry_get(m_view, 0, 0, &width, &height);
 
87
    m_context3D->viewport(0, 0, width, height);
 
88
 
 
89
    m_textureMapper->beginPainting();
 
90
    m_rootTextureMapperLayer->paint();
 
91
    m_textureMapper->endPainting();
 
92
}
 
93
 
 
94
void AcceleratedCompositingContext::attachRootGraphicsLayer(GraphicsLayer* rootLayer)
 
95
{
 
96
    if (!rootLayer) {
 
97
        m_rootGraphicsLayer.clear();
 
98
        m_rootTextureMapperLayer = 0;
 
99
        return;
 
100
    }
 
101
 
 
102
    m_rootGraphicsLayer = WebCore::GraphicsLayer::create(0);
 
103
    m_rootTextureMapperLayer = toTextureMapperLayer(m_rootGraphicsLayer.get());
 
104
    m_rootGraphicsLayer->addChild(rootLayer);
 
105
    m_rootGraphicsLayer->setDrawsContent(false);
 
106
    m_rootGraphicsLayer->setMasksToBounds(false);
 
107
    m_rootGraphicsLayer->setSize(WebCore::IntSize(1, 1));
 
108
 
 
109
    m_textureMapper = TextureMapperGL::create();
 
110
    m_rootTextureMapperLayer->setTextureMapper(m_textureMapper.get());
 
111
 
 
112
    m_rootGraphicsLayer->flushCompositingStateForThisLayerOnly();
 
113
}
 
114
 
 
115
GraphicsContext3D* AcceleratedCompositingContext::context()
 
116
{
 
117
    return m_context3D.get();
 
118
}
 
119
 
 
120
} // namespace WebCore
 
121
 
 
122
#endif // USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)