blob: 82b194f9ac2cf99d7d36a869b8c33371cfc19d60 [file] [log] [blame]
// Copyright 2018 The Chromium 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 CHROME_BROWSER_VR_BASE_GRAPHICS_DELEGATE_H_
#define CHROME_BROWSER_VR_BASE_GRAPHICS_DELEGATE_H_
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "chrome/browser/vr/graphics_delegate.h"
namespace gl {
class GLContext;
class GLShareGroup;
class GLSurface;
} // namespace gl
namespace vr {
class VR_EXPORT BaseGraphicsDelegate : public GraphicsDelegate {
public:
BaseGraphicsDelegate();
~BaseGraphicsDelegate() override;
// GraphicsDelegate implementation.
bool Initialize(const scoped_refptr<gl::GLSurface>& surface) override;
bool RunInSkiaContext(base::OnceClosure callback) override;
protected:
void SwapSurfaceBuffers();
private:
enum ContextId { kNone = -1, kMainContext, kSkiaContext, kNumContexts };
bool MakeContextCurrent(ContextId context_id);
scoped_refptr<gl::GLSurface> surface_;
scoped_refptr<gl::GLShareGroup> share_group_;
scoped_refptr<gl::GLContext> contexts_[kNumContexts];
ContextId curr_context_id_ = kNone;
DISALLOW_COPY_AND_ASSIGN(BaseGraphicsDelegate);
};
} // namespace vr
#endif // CHROME_BROWSER_VR_BASE_GRAPHICS_DELEGATE_H_