1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PBufferSurfaceCGL.cpp: an implementation of egl::Surface for PBuffers for the CLG backend,
// currently implemented using renderbuffers
#include "libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h"
#include "common/debug.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h"
namespace rx
{
PbufferSurfaceCGL::PbufferSurfaceCGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height,
const FunctionsGL *functions)
: SurfaceGL(state, renderer),
mWidth(width),
mHeight(height),
mFunctions(functions),
mStateManager(renderer->getStateManager()),
mRenderer(renderer),
mFramebuffer(0),
mColorRenderbuffer(0),
mDSRenderbuffer(0)
{
}
PbufferSurfaceCGL::~PbufferSurfaceCGL()
{
if (mFramebuffer != 0)
{
mFunctions->deleteFramebuffers(1, &mFramebuffer);
mFramebuffer = 0;
}
if (mColorRenderbuffer != 0)
{
mFunctions->deleteRenderbuffers(1, &mColorRenderbuffer);
mColorRenderbuffer = 0;
}
if (mDSRenderbuffer != 0)
{
mFunctions->deleteRenderbuffers(1, &mDSRenderbuffer);
mDSRenderbuffer = 0;
}
}
egl::Error PbufferSurfaceCGL::initialize()
{
mFunctions->genRenderbuffers(1, &mColorRenderbuffer);
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, mWidth, mHeight);
mFunctions->genRenderbuffers(1, &mDSRenderbuffer);
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mDSRenderbuffer);
mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, mWidth, mHeight);
mFunctions->genFramebuffers(1, &mFramebuffer);
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
mFunctions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
mColorRenderbuffer);
mFunctions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, mDSRenderbuffer);
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceCGL::makeCurrent()
{
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceCGL::swap()
{
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceCGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceCGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceCGL::bindTexImage(gl::Texture *texture, EGLint buffer)
{
UNIMPLEMENTED();
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceCGL::releaseTexImage(EGLint buffer)
{
UNIMPLEMENTED();
return egl::Error(EGL_SUCCESS);
}
void PbufferSurfaceCGL::setSwapInterval(EGLint interval)
{
}
EGLint PbufferSurfaceCGL::getWidth() const
{
return mWidth;
}
EGLint PbufferSurfaceCGL::getHeight() const
{
return mHeight;
}
EGLint PbufferSurfaceCGL::isPostSubBufferSupported() const
{
UNIMPLEMENTED();
return EGL_FALSE;
}
EGLint PbufferSurfaceCGL::getSwapBehavior() const
{
return EGL_BUFFER_PRESERVED;
}
FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state)
{
// TODO(cwallez) assert it happens only once?
return new FramebufferGL(mFramebuffer, state, mFunctions, mRenderer->getWorkarounds(),
mRenderer->getBlitter(), mStateManager);
}
}
|