Hash :
62baf0cf
Author :
Date :
2016-05-19T13:13:36
Add a shared egl::SurfaceState struct. This structure can share GL-level properties (immutably) with the implementation. BUG=angleproject:1369 Change-Id: I1e9406f18b6b88bb7db2a8f87b5e6d547cc7ecb1 Reviewed-on: https://chromium-review.googlesource.com/342061 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
//
// 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.
//
// DisplayOzone.h: Ozone implementation of egl::Display
#ifndef LIBANGLE_RENDERER_GL_EGL_OZONE_DISPLAYOZONE_H_
#define LIBANGLE_RENDERER_GL_EGL_OZONE_DISPLAYOZONE_H_
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <string>
#include "libANGLE/renderer/gl/DisplayGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h"
struct gbm_device;
struct gbm_bo;
namespace rx
{
class FramebufferGL;
// TODO(fjhenigman) Implement swap control. The following struct will be used for that.
// State-tracking data for the swap control to allow DisplayOzone to remember per
// drawable information for swap control.
struct SwapControlData final
{
SwapControlData();
// Set by the drawable
int targetSwapInterval;
// DisplayOzone-side state-tracking
int maxSwapInterval;
int currentSwapInterval;
};
class DisplayOzone final : public DisplayGL
{
public:
struct NativeWindow
{
int32_t x;
int32_t y;
int32_t width;
int32_t height;
int32_t borderWidth;
int32_t borderHeight;
int32_t visible;
int32_t depth;
};
class Buffer final : angle::NonCopyable
{
public:
Buffer(DisplayOzone *display,
uint32_t useFlags,
uint32_t gbmFormat,
uint32_t drmFormat,
uint32_t drmFormatFB,
int depthBits,
int stencilBits);
~Buffer();
bool initialize(const NativeWindow *window);
bool initialize(int32_t width, int32_t height);
void reset();
bool resize(int32_t width, int32_t height);
FramebufferGL *framebufferGL(const gl::FramebufferState &state);
void present();
uint32_t getDRMFB();
void bindTexImage();
GLuint getTexture();
int32_t getWidth() const { return mWidth; }
int32_t getHeight() const { return mHeight; }
GLuint getGLFB() const { return mGLFB; }
const NativeWindow *getNative() const { return mNative; }
private:
DisplayOzone *mDisplay;
const NativeWindow *mNative;
int mWidth;
int mHeight;
const int mDepthBits;
const int mStencilBits;
const uint32_t mUseFlags;
const uint32_t mGBMFormat;
const uint32_t mDRMFormat;
const uint32_t mDRMFormatFB;
gbm_bo *mBO;
int mDMABuf;
bool mHasDRMFB;
uint32_t mDRMFB;
EGLImageKHR mImage;
GLuint mColorBuffer;
GLuint mDSBuffer;
GLuint mGLFB;
GLuint mTexture;
};
DisplayOzone();
~DisplayOzone() override;
egl::Error initialize(egl::Display *display) override;
void terminate() override;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) override;
egl::ConfigSet generateConfigs() const override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
bool isValidNativeWindow(EGLNativeWindowType window) const override;
egl::Error getDevice(DeviceImpl **device) override;
std::string getVendorString() const override;
egl::Error waitClient() const override;
egl::Error waitNative(EGLint engine,
egl::Surface *drawSurface,
egl::Surface *readSurface) const override;
// TODO(fjhenigman) Implement this.
// Swap interval can be set globally or per drawable.
// This function will make sure the drawable's swap interval is the
// one required so that the subsequent swapBuffers acts as expected.
void setSwapInterval(EGLSurface drawable, SwapControlData *data);
egl::Error getDriverVersion(std::string *version) const override;
private:
const FunctionsGL *getFunctionsGL() const override;
EGLContext initializeContext(EGLConfig config, const egl::AttributeMap &eglAttributes);
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override;
GLuint makeShader(GLuint type, const char *src);
void drawBuffer(Buffer *buffer);
void drawWithBlit(Buffer *buffer);
void drawWithTexture(Buffer *buffer);
void flushGL();
void presentScreen();
static void pageFlipHandler(int fd,
unsigned int sequence,
unsigned int tv_sec,
unsigned int tv_usec,
void *data);
void pageFlipHandler(unsigned int sequence, uint64_t tv);
EGLConfig mContextConfig;
EGLContext mContext;
// TODO(fjhenigman) Implement swap control. The following stuff will be used for that.
enum class SwapControl
{
ABSENT,
EXT,
MESA,
SGI,
};
SwapControl mSwapControl;
int mMinSwapInterval;
int mMaxSwapInterval;
int mCurrentSwapInterval;
FunctionsEGLDL *mEGL;
FunctionsGL *mFunctionsGL;
gbm_device *mGBM;
drmModeConnectorPtr mConnector;
drmModeModeInfoPtr mMode;
drmModeCrtcPtr mCRTC;
bool mSetCRTC;
int32_t mWidth;
int32_t mHeight;
// Three scanout buffers cycle through four states. The state of a buffer
// is indicated by which of these pointers points to it.
// TODO(fjhenigman) It might be simpler/clearer to use a ring buffer.
Buffer *mScanning;
Buffer *mPending;
Buffer *mDrawing;
Buffer *mUnused;
GLuint mProgram;
GLuint mVertexShader;
GLuint mFragmentShader;
GLuint mVertexBuffer;
GLuint mIndexBuffer;
GLint mCenterUniform;
GLint mWindowSizeUniform;
GLint mBorderSizeUniform;
GLint mDepthUniform;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_OZONE_DISPLAYOZONE_H_