Moving graphics context creation around to hide actual creation.

Makes it easier to support APIs that don't have a concept of sharing.
This commit is contained in:
Ben Vanik
2015-11-10 17:38:57 -08:00
parent d8fa54ffc4
commit 6c95ca1cdb
16 changed files with 234 additions and 97 deletions

View File

@@ -29,18 +29,14 @@ namespace ui {
namespace gl {
class GLImmediateDrawer;
class GLProvider;
class GLContext : public GraphicsContext {
public:
static std::unique_ptr<GLContext> Create(Window* target_window,
GLContext* share_context = nullptr);
~GLContext() override;
HDC dc() const { return dc_; }
std::unique_ptr<GraphicsContext> CreateShared() override;
ImmediateDrawer* immediate_drawer() override;
bool is_current() override;
@@ -53,10 +49,18 @@ class GLContext : public GraphicsContext {
Blitter* blitter() { return &blitter_; }
private:
explicit GLContext(Window* target_window);
GLContext(Window* target_window, HGLRC glrc);
friend class GLProvider;
bool Initialize(Window* target_window, GLContext* share_context);
static std::unique_ptr<GLContext> Create(GraphicsProvider* provider,
Window* target_window,
GLContext* share_context = nullptr);
static std::unique_ptr<GLContext> CreateOffscreen(GraphicsProvider* provider,
GLContext* parent_context);
private:
GLContext(GraphicsProvider* provider, Window* target_window);
bool Initialize(GLContext* share_context);
void AssertExtensionsPresent();
void SetupDebugging();