1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "gpu/command_buffer/service/feature_info.h"
11 #include "ui/gfx/size.h"
23 class CommandBufferService;
24 class GpuControlService;
25 class GpuMemoryBufferFactory;
35 class GLES2Implementation;
46 // The size of the backbuffer.
48 // If not null will share resources with this context.
49 GLManager* share_group_manager;
50 // If not null will share a mailbox manager with this context.
51 GLManager* share_mailbox_manager;
52 // If not null will create a virtual manager based on this context.
53 GLManager* virtual_manager;
54 // Whether or not glBindXXX generates a resource.
55 bool bind_generates_resource;
56 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs.
57 bool lose_context_when_out_of_memory;
58 // Whether or not it's ok to lose the context.
59 bool context_lost_allowed;
60 // Image manager to be used.
61 gles2::ImageManager* image_manager;
62 // GpuMemoryBuffer factory to be used.
63 GpuMemoryBufferFactory* gpu_memory_buffer_factory;
68 void Initialize(const Options& options);
73 void SetSurface(gfx::GLSurface* surface);
75 gles2::GLES2Decoder* decoder() const {
76 return decoder_.get();
79 gles2::MailboxManager* mailbox_manager() const {
80 return mailbox_manager_.get();
83 gfx::GLShareGroup* share_group() const {
84 return share_group_.get();
87 gles2::GLES2Implementation* gles2_implementation() const {
88 return gles2_implementation_.get();
91 gfx::GLContext* context() {
92 return context_.get();
95 const gpu::gles2::FeatureInfo::Workarounds& workarounds() const;
99 bool GetBufferChanged(int32 transfer_buffer_id);
100 void SetupBaseContext();
102 scoped_refptr<gles2::MailboxManager> mailbox_manager_;
103 scoped_refptr<gfx::GLShareGroup> share_group_;
104 scoped_ptr<CommandBufferService> command_buffer_;
105 scoped_ptr<GpuControlService> gpu_control_;
106 scoped_ptr<gles2::GLES2Decoder> decoder_;
107 scoped_ptr<GpuScheduler> gpu_scheduler_;
108 scoped_refptr<gfx::GLSurface> surface_;
109 scoped_refptr<gfx::GLContext> context_;
110 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_;
111 scoped_ptr<TransferBuffer> transfer_buffer_;
112 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_;
113 bool context_lost_allowed_;
115 // Used on Android to virtualize GL for all contexts.
116 static int use_count_;
117 static scoped_refptr<gfx::GLShareGroup>* base_share_group_;
118 static scoped_refptr<gfx::GLSurface>* base_surface_;
119 static scoped_refptr<gfx::GLContext>* base_context_;
124 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_