Hash :
fb0580a6
Author :
Date :
2014-11-27T14:03:52
MANGLE egl::Surface. This class has its fingers in a lot of other classes. In particular, we will likely need to revisit the context lost handling methods when we implement the robustness extensions on top of desktop GL. For now, we can leave them tied pretty tightly to the D3D implementation. BUG=angle:795 Change-Id: I9b3ac90dfd393f52c5b49bc2bd6b97fb5536ed91 Reviewed-on: https://chromium-review.googlesource.com/228916 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
//
// Copyright (c) 2002-2014 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.
//
// Surface.cpp: Implements the egl::Surface class, representing a drawing surface
// such as the client area of a window, including any back buffers.
// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
#include "libANGLE/Surface.h"
#include "libANGLE/Config.h"
#include "libANGLE/Texture.h"
#include "libANGLE/renderer/SurfaceImpl.h"
namespace egl
{
Surface::Surface(rx::SurfaceImpl *impl)
: mImplementation(impl),
// FIXME: Determine actual pixel aspect ratio
mPixelAspectRatio(static_cast<EGLint>(1.0 * EGL_DISPLAY_SCALING)),
mRenderBuffer(EGL_BACK_BUFFER),
mSwapBehavior(EGL_BUFFER_PRESERVED),
mTexture(NULL)
{
setSwapInterval(1);
}
Surface::~Surface()
{
if (mTexture)
{
if (mImplementation)
{
mImplementation->releaseTexImage(mTexture->id());
}
mTexture->releaseTexImage();
mTexture = NULL;
}
SafeDelete(mImplementation);
}
Error Surface::initialize()
{
return mImplementation->initialize();
}
EGLNativeWindowType Surface::getWindowHandle() const
{
return mImplementation->getWindowHandle();
}
Error Surface::swap()
{
return mImplementation->swap();
}
Error Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{
if (!isPostSubBufferSupported())
{
// Spec is not clear about how this should be handled.
return Error(EGL_SUCCESS);
}
return mImplementation->postSubBuffer(x, y, width, height);
}
Error Surface::querySurfacePointerANGLE(EGLint attribute, void **value)
{
return mImplementation->querySurfacePointerANGLE(attribute, value);
}
EGLint Surface::isPostSubBufferSupported() const
{
return mImplementation->isPostSubBufferSupported();
}
void Surface::setSwapInterval(EGLint interval)
{
mImplementation->setSwapInterval(interval);
}
EGLint Surface::getConfigID() const
{
return mImplementation->getConfig()->mConfigID;
}
EGLint Surface::getPixelAspectRatio() const
{
return mPixelAspectRatio;
}
EGLenum Surface::getRenderBuffer() const
{
return mRenderBuffer;
}
EGLenum Surface::getSwapBehavior() const
{
return mSwapBehavior;
}
EGLenum Surface::getTextureFormat() const
{
return mImplementation->getTextureFormat();
}
EGLenum Surface::getTextureTarget() const
{
return mImplementation->getTextureTarget();
}
EGLint Surface::isFixedSize() const
{
return mImplementation->isFixedSize();
}
EGLenum Surface::getFormat() const
{
return mImplementation->getFormat();
}
EGLint Surface::getWidth() const
{
return mImplementation->getWidth();
}
EGLint Surface::getHeight() const
{
return mImplementation->getHeight();
}
Error Surface::bindTexImage(gl::Texture2D *texture, EGLint buffer)
{
ASSERT(!mTexture);
texture->bindTexImage(this);
mTexture = texture;
return mImplementation->bindTexImage(buffer);
}
Error Surface::releaseTexImage(EGLint buffer)
{
ASSERT(mTexture);
gl::Texture2D *boundTexture = mTexture;
mTexture = NULL;
boundTexture->releaseTexImage();
return mImplementation->releaseTexImage(buffer);
}
}