cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / gpu / command_buffer / client / share_group.h
blob68ea6a9895a536b10e43d3f996b42eca33724473
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_CLIENT_SHARE_GROUP_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_
8 #include <GLES2/gl2.h>
9 #include "base/memory/scoped_ptr.h"
10 #include "gles2_impl_export.h"
11 #include "gpu/command_buffer/client/ref_counted.h"
12 #include "gpu/command_buffer/common/gles2_cmd_format.h"
14 namespace gpu {
15 namespace gles2 {
17 class GLES2Implementation;
18 class GLES2ImplementationTest;
19 class ProgramInfoManager;
21 typedef void (GLES2Implementation::*DeleteFn)(GLsizei n, const GLuint* ids);
23 // Base class for IdHandlers
24 class IdHandlerInterface {
25 public:
26 IdHandlerInterface() { }
27 virtual ~IdHandlerInterface() { }
29 // Makes some ids at or above id_offset.
30 virtual void MakeIds(
31 GLES2Implementation* gl_impl,
32 GLuint id_offset, GLsizei n, GLuint* ids) = 0;
34 // Frees some ids.
35 virtual bool FreeIds(
36 GLES2Implementation* gl_impl, GLsizei n, const GLuint* ids,
37 DeleteFn delete_fn) = 0;
39 // Marks an id as used for glBind functions. id = 0 does nothing.
40 virtual bool MarkAsUsedForBind(GLuint id) = 0;
43 // ShareGroup manages shared resources for contexts that are sharing resources.
44 class GLES2_IMPL_EXPORT ShareGroup
45 : public gpu::RefCountedThreadSafe<ShareGroup> {
46 public:
47 ShareGroup(bool bind_generates_resource);
49 bool bind_generates_resource() const {
50 return bind_generates_resource_;
53 bool Initialize();
55 IdHandlerInterface* GetIdHandler(int namespace_id) const {
56 return id_handlers_[namespace_id].get();
59 ProgramInfoManager* program_info_manager() {
60 return program_info_manager_.get();
63 private:
64 friend class gpu::RefCountedThreadSafe<ShareGroup>;
65 friend class gpu::gles2::GLES2ImplementationTest;
66 ~ShareGroup();
68 // Install a new program info manager. Used for testing only;
69 void set_program_info_manager(ProgramInfoManager* manager);
71 scoped_ptr<IdHandlerInterface> id_handlers_[id_namespaces::kNumIdNamespaces];
72 scoped_ptr<ProgramInfoManager> program_info_manager_;
74 bool bind_generates_resource_;
76 DISALLOW_COPY_AND_ASSIGN(ShareGroup);
79 } // namespace gles2
80 } // namespace gpu
82 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_