OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "gpu/command_buffer/service/gl_utils.h" | 13 #include "gpu/command_buffer/service/gl_utils.h" |
14 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 14 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
15 | 15 |
16 namespace gpu { | 16 namespace gpu { |
17 namespace gles2 { | 17 namespace gles2 { |
18 | 18 |
19 // This class keeps track of the frambebuffers and their attached renderbuffers | 19 // This class keeps track of the frambebuffers and their attached renderbuffers |
20 // so we can correctly clear them. | 20 // so we can correctly clear them. |
21 class FramebufferManager { | 21 class FramebufferManager { |
22 public: | 22 public: |
23 // Info about Framebuffers currently in the system. | 23 // Info about Framebuffers currently in the system. |
24 class FramebufferInfo : public base::RefCounted<FramebufferInfo> { | 24 class FramebufferInfo : public base::RefCounted<FramebufferInfo> { |
25 public: | 25 public: |
26 typedef scoped_refptr<FramebufferInfo> Ref; | 26 typedef scoped_refptr<FramebufferInfo> Ref; |
27 | 27 |
28 explicit FramebufferInfo(GLuint framebuffer_id) | 28 explicit FramebufferInfo(GLuint service_id) |
29 : framebuffer_id_(framebuffer_id) { | 29 : service_id_(service_id) { |
30 } | 30 } |
31 | 31 |
32 GLuint framebuffer_id() const { | 32 GLuint service_id() const { |
33 return framebuffer_id_; | 33 return service_id_; |
34 } | 34 } |
35 | 35 |
36 // Attaches a renderbuffer to a particlar attachment. | 36 // Attaches a renderbuffer to a particlar attachment. |
37 // Pass null to detach. | 37 // Pass null to detach. |
38 void AttachRenderbuffer( | 38 void AttachRenderbuffer( |
39 GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer); | 39 GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer); |
40 | 40 |
41 bool IsDeleted() { | 41 bool IsDeleted() { |
42 return framebuffer_id_ == 0; | 42 return service_id_ == 0; |
43 } | 43 } |
44 | 44 |
45 private: | 45 private: |
46 friend class FramebufferManager; | 46 friend class FramebufferManager; |
47 friend class base::RefCounted<FramebufferInfo>; | 47 friend class base::RefCounted<FramebufferInfo>; |
48 | 48 |
49 ~FramebufferInfo() { } | 49 ~FramebufferInfo() { } |
50 | 50 |
51 void MarkAsDeleted() { | 51 void MarkAsDeleted() { |
52 framebuffer_id_ = 0; | 52 service_id_ = 0; |
53 renderbuffers_.clear(); | 53 renderbuffers_.clear(); |
54 } | 54 } |
55 | 55 |
56 // Service side framebuffer id. | 56 // Service side framebuffer id. |
57 GLuint framebuffer_id_; | 57 GLuint service_id_; |
58 | 58 |
59 // A map of attachments to renderbuffers. | 59 // A map of attachments to renderbuffers. |
60 typedef std::map<GLenum, RenderbufferManager::RenderbufferInfo::Ref> | 60 typedef std::map<GLenum, RenderbufferManager::RenderbufferInfo::Ref> |
61 AttachmentToRenderbufferMap; | 61 AttachmentToRenderbufferMap; |
62 AttachmentToRenderbufferMap renderbuffers_; | 62 AttachmentToRenderbufferMap renderbuffers_; |
63 }; | 63 }; |
64 | 64 |
65 FramebufferManager() { } | 65 FramebufferManager() { } |
66 | 66 |
67 // Creates a FramebufferInfo for the given framebuffer. | 67 // Creates a FramebufferInfo for the given framebuffer. |
68 void CreateFramebufferInfo(GLuint framebuffer_id); | 68 void CreateFramebufferInfo(GLuint client_id, GLuint service_id); |
69 | 69 |
70 // Gets the framebuffer info for the given framebuffer. | 70 // Gets the framebuffer info for the given framebuffer. |
71 FramebufferInfo* GetFramebufferInfo(GLuint framebuffer_id); | 71 FramebufferInfo* GetFramebufferInfo(GLuint client_id); |
72 | 72 |
73 // Removes a framebuffer info for the given framebuffer. | 73 // Removes a framebuffer info for the given framebuffer. |
74 void RemoveFramebufferInfo(GLuint framebuffer_id); | 74 void RemoveFramebufferInfo(GLuint client_id); |
75 | 75 |
76 private: | 76 private: |
77 // Info for each framebuffer in the system. | 77 // Info for each framebuffer in the system. |
78 // TODO(gman): Choose a faster container. | 78 // TODO(gman): Choose a faster container. |
79 typedef std::map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap; | 79 typedef std::map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap; |
80 FramebufferInfoMap framebuffer_infos_; | 80 FramebufferInfoMap framebuffer_infos_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); | 82 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace gles2 | 85 } // namespace gles2 |
86 } // namespace gpu | 86 } // namespace gpu |
87 | 87 |
88 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 88 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
89 | 89 |
90 | 90 |
OLD | NEW |