Hash :
95401dbb
Author :
Date :
2016-12-15T11:27:48
Surface: Pass DisplayImpl to initialize and swap. In new back-ends (Vulkan) this will allow us to avoid storing a ref to the Renderer in the Surface class. BUG=angleproject:1319 Change-Id: I3b3f50893070d2993e4e91dd82ee539a083b3727 Reviewed-on: https://chromium-review.googlesource.com/419837 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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
//
// Copyright (c) 2016 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.
//
// SurfaceEGL.cpp: EGL implementation of egl::Surface
#include "libANGLE/renderer/gl/egl/SurfaceEGL.h"
#include "common/debug.h"
namespace rx
{
SurfaceEGL::SurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer)
: SurfaceGL(state, renderer),
mEGL(egl),
mConfig(config),
mAttribList(attribList),
mSurface(EGL_NO_SURFACE),
mContext(context)
{
}
SurfaceEGL::~SurfaceEGL()
{
if (mSurface != EGL_NO_SURFACE)
{
EGLBoolean success = mEGL->destroySurface(mSurface);
ASSERT(success == EGL_TRUE);
}
}
egl::Error SurfaceEGL::makeCurrent()
{
EGLBoolean success = mEGL->makeCurrent(mSurface, mContext);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglMakeCurrent failed");
}
return egl::Error(EGL_SUCCESS);
}
egl::Error SurfaceEGL::swap(const DisplayImpl *displayImpl)
{
EGLBoolean success = mEGL->swapBuffers(mSurface);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglSwapBuffers failed");
}
return egl::Error(EGL_SUCCESS);
}
egl::Error SurfaceEGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{
UNIMPLEMENTED();
return egl::Error(EGL_BAD_SURFACE);
}
egl::Error SurfaceEGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
return egl::Error(EGL_BAD_SURFACE);
}
egl::Error SurfaceEGL::bindTexImage(gl::Texture *texture, EGLint buffer)
{
EGLBoolean success = mEGL->bindTexImage(mSurface, buffer);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglBindTexImage failed");
}
return egl::Error(EGL_SUCCESS);
}
egl::Error SurfaceEGL::releaseTexImage(EGLint buffer)
{
EGLBoolean success = mEGL->releaseTexImage(mSurface, buffer);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglReleaseTexImage failed");
}
return egl::Error(EGL_SUCCESS);
}
void SurfaceEGL::setSwapInterval(EGLint interval)
{
EGLBoolean success = mEGL->swapInterval(interval);
if (success == EGL_FALSE)
{
ERR("eglSwapInterval error 0x%04x", mEGL->getError());
ASSERT(false);
}
}
EGLint SurfaceEGL::getWidth() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_WIDTH, &value);
ASSERT(success == EGL_TRUE);
return value;
}
EGLint SurfaceEGL::getHeight() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_HEIGHT, &value);
ASSERT(success == EGL_TRUE);
return value;
}
EGLint SurfaceEGL::isPostSubBufferSupported() const
{
UNIMPLEMENTED();
return 0;
}
EGLint SurfaceEGL::getSwapBehavior() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_SWAP_BEHAVIOR, &value);
ASSERT(success == EGL_TRUE);
return value;
}
} // namespace rx