blob: 376b3fef7ede9117ab942b4da3c24ef7badcb309 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_EGL_WINDOW_SURFACE_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_EGL_WINDOW_SURFACE_H_
#include <EGL/egl.h>
#include "flutter/fml/macros.h"
#include "flutter/shell/platform/windows/egl/surface.h"
namespace flutter {
namespace egl {
// An EGL surface used to render a Flutter view to a win32 HWND.
//
// This enables automatic error logging and mocking.
class WindowSurface : public Surface {
public:
WindowSurface(EGLDisplay display,
EGLContext context,
EGLSurface surface,
size_t width,
size_t height);
// If enabled, makes the surface's buffer swaps block until the v-blank.
//
// If disabled, allows one thread to swap multiple buffers per v-blank
// but can result in screen tearing if the system compositor is disabled.
//
// This binds the EGL context and surface to the current thread.
virtual bool SetVSyncEnabled(bool enabled);
// Get the surface's width in physical pixels.
virtual size_t width() const;
// Get the surface's height in physical pixels.
virtual size_t height() const;
// Get whether the surface's buffer swap blocks until the v-blank.
virtual bool vsync_enabled() const;
private:
size_t width_ = 0;
size_t height_ = 0;
bool vsync_enabled_ = true;
FML_DISALLOW_COPY_AND_ASSIGN(WindowSurface);
};
} // namespace egl
} // namespace flutter
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_EGL_WINDOW_SURFACE_H_