#ifndef GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_
#define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "ui/gfx/size.h"
namespace gfx {
class GLContext;
class GLShareGroup;
class GLSurface;
}
namespace gpu {
class CommandBufferService;
class GpuControlService;
class GpuMemoryBufferFactory;
class GpuScheduler;
class TransferBuffer;
namespace gles2 {
class ContextGroup;
class MailboxManager;
class GLES2Decoder;
class GLES2CmdHelper;
class GLES2Implementation;
class ImageFactory;
class ImageManager;
class ShareGroup;
};
class GLManager {
public:
struct Options {
Options();
gfx::Size size;
GLManager* share_group_manager;
GLManager* share_mailbox_manager;
GLManager* virtual_manager;
bool bind_generates_resource;
bool lose_context_when_out_of_memory;
bool context_lost_allowed;
gles2::ImageManager* image_manager;
GpuMemoryBufferFactory* gpu_memory_buffer_factory;
};
GLManager();
~GLManager();
void Initialize(const Options& options);
void Destroy();
void MakeCurrent();
void SetSurface(gfx::GLSurface* surface);
gles2::GLES2Decoder* decoder() const {
return decoder_.get();
}
gles2::MailboxManager* mailbox_manager() const {
return mailbox_manager_.get();
}
gfx::GLShareGroup* share_group() const {
return share_group_.get();
}
gles2::GLES2Implementation* gles2_implementation() const {
return gles2_implementation_.get();
}
gfx::GLContext* context() {
return context_.get();
}
const gpu::gles2::FeatureInfo::Workarounds& workarounds() const;
private:
void PumpCommands();
bool GetBufferChanged(int32 transfer_buffer_id);
void SetupBaseContext();
scoped_refptr<gles2::MailboxManager> mailbox_manager_;
scoped_refptr<gfx::GLShareGroup> share_group_;
scoped_ptr<CommandBufferService> command_buffer_;
scoped_ptr<GpuControlService> gpu_control_;
scoped_ptr<gles2::GLES2Decoder> decoder_;
scoped_ptr<GpuScheduler> gpu_scheduler_;
scoped_refptr<gfx::GLSurface> surface_;
scoped_refptr<gfx::GLContext> context_;
scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_;
scoped_ptr<TransferBuffer> transfer_buffer_;
scoped_ptr<gles2::GLES2Implementation> gles2_implementation_;
bool context_lost_allowed_;
static int use_count_;
static scoped_refptr<gfx::GLShareGroup>* base_share_group_;
static scoped_refptr<gfx::GLSurface>* base_surface_;
static scoped_refptr<gfx::GLContext>* base_context_;
};
}
#endif