1/*
2 * Copyright (C) 2012 Intel Corporation. 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 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "GLPlatformSurface.h"
28
29#if USE(ACCELERATED_COMPOSITING)
30
31#if USE(GLX)
32#include "GLXSurface.h"
33#endif
34
35#if USE(EGL)
36#include "EGLSurface.h"
37#endif
38
39#include "NotImplemented.h"
40
41namespace WebCore {
42
43static GLPlatformSurface* m_currentDrawable = 0;
44
45PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes)
46{
47    OwnPtr<GLPlatformSurface> surface;
48#if USE(GLX)
49    surface = adoptPtr(new GLXOffScreenSurface(attributes));
50#else
51    surface = EGLOffScreenSurface::createOffScreenSurface(attributes);
52#endif
53
54    if (surface && surface->drawable())
55        return surface.release();
56
57    return nullptr;
58}
59
60GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
61    : m_sharedDisplay(0)
62    , m_drawable(0)
63    , m_bufferHandle(0)
64{
65}
66
67GLPlatformSurface::~GLPlatformSurface()
68{
69    if (m_currentDrawable == this)
70        m_currentDrawable = 0;
71}
72
73PlatformBufferHandle GLPlatformSurface::handle() const
74{
75    return m_bufferHandle;
76}
77
78PlatformDrawable GLPlatformSurface::drawable() const
79{
80    return m_drawable;
81}
82
83const IntRect& GLPlatformSurface::geometry() const
84{
85    return m_rect;
86}
87
88PlatformDisplay GLPlatformSurface::sharedDisplay() const
89{
90    return m_sharedDisplay;
91}
92
93PlatformSurfaceConfig GLPlatformSurface::configuration()
94{
95    return 0;
96}
97
98void GLPlatformSurface::swapBuffers()
99{
100    notImplemented();
101}
102
103bool GLPlatformSurface::isCurrentDrawable() const
104{
105    return m_currentDrawable == this;
106}
107
108void GLPlatformSurface::onMakeCurrent()
109{
110    m_currentDrawable = this;
111}
112
113void GLPlatformSurface::updateContents(const uint32_t)
114{
115}
116
117void GLPlatformSurface::setGeometry(const IntRect&)
118{
119}
120
121void GLPlatformSurface::destroy()
122{
123    if (m_currentDrawable == this)
124        m_currentDrawable = 0;
125}
126
127GLPlatformSurface::SurfaceAttributes GLPlatformSurface::attributes() const
128{
129    return GLPlatformSurface::Default;
130}
131
132}
133
134#endif
135