OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "gpu/command_buffer/service/mailbox_manager_sync.h" | 5 #include "gpu/command_buffer/service/mailbox_manager_sync.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <queue> | 10 #include <queue> |
11 | 11 |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "gpu/command_buffer/common/sync_token.h" | 14 #include "gpu/command_buffer/common/sync_token.h" |
15 #include "gpu/command_buffer/service/texture_manager.h" | 15 #include "gpu/command_buffer/service/texture_manager.h" |
16 #include "ui/gl/gl_fence.h" | 16 #include "ui/gl/gl_fence.h" |
17 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
18 | 18 |
19 #if !defined(OS_MACOSX) | 19 #if !defined(OS_MACOSX) |
20 #include "ui/gl/gl_fence_egl.h" | 20 #include "ui/gl/gl_fence_egl.h" |
21 #endif | 21 #endif |
22 | 22 |
23 namespace gpu { | 23 namespace gpu { |
24 namespace gles2 { | 24 namespace gles2 { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 base::LazyInstance<base::Lock> g_lock = LAZY_INSTANCE_INITIALIZER; | 28 base::LazyInstance<base::Lock>::DestructorAtExit g_lock = |
| 29 LAZY_INSTANCE_INITIALIZER; |
29 | 30 |
30 #if !defined(OS_MACOSX) | 31 #if !defined(OS_MACOSX) |
31 typedef std::map<SyncToken, std::unique_ptr<gl::GLFence>> SyncTokenToFenceMap; | 32 typedef std::map<SyncToken, std::unique_ptr<gl::GLFence>> SyncTokenToFenceMap; |
32 base::LazyInstance<SyncTokenToFenceMap> g_sync_point_to_fence = | 33 base::LazyInstance<SyncTokenToFenceMap>::DestructorAtExit |
33 LAZY_INSTANCE_INITIALIZER; | 34 g_sync_point_to_fence = LAZY_INSTANCE_INITIALIZER; |
34 base::LazyInstance<std::queue<SyncTokenToFenceMap::iterator>> g_sync_points = | 35 base::LazyInstance<std::queue<SyncTokenToFenceMap::iterator>>::DestructorAtExit |
35 LAZY_INSTANCE_INITIALIZER; | 36 g_sync_points = LAZY_INSTANCE_INITIALIZER; |
36 #endif | 37 #endif |
37 | 38 |
38 void CreateFenceLocked(const SyncToken& sync_token) { | 39 void CreateFenceLocked(const SyncToken& sync_token) { |
39 #if !defined(OS_MACOSX) | 40 #if !defined(OS_MACOSX) |
40 g_lock.Get().AssertAcquired(); | 41 g_lock.Get().AssertAcquired(); |
41 if (gl::GetGLImplementation() == gl::kGLImplementationMockGL || | 42 if (gl::GetGLImplementation() == gl::kGLImplementationMockGL || |
42 gl::GetGLImplementation() == gl::kGLImplementationStubGL) | 43 gl::GetGLImplementation() == gl::kGLImplementationStubGL) |
43 return; | 44 return; |
44 | 45 |
45 std::queue<SyncTokenToFenceMap::iterator>& sync_points = g_sync_points.Get(); | 46 std::queue<SyncTokenToFenceMap::iterator>& sync_points = g_sync_points.Get(); |
(...skipping 24 matching lines...) Expand all Loading... |
70 if (fence_it != g_sync_point_to_fence.Get().end()) { | 71 if (fence_it != g_sync_point_to_fence.Get().end()) { |
71 fence_it->second->ServerWait(); | 72 fence_it->second->ServerWait(); |
72 } | 73 } |
73 #endif | 74 #endif |
74 } | 75 } |
75 | 76 |
76 static const unsigned kNewTextureVersion = 1; | 77 static const unsigned kNewTextureVersion = 1; |
77 | 78 |
78 } // anonymous namespace | 79 } // anonymous namespace |
79 | 80 |
80 base::LazyInstance<MailboxManagerSync::TextureGroup::MailboxToGroupMap> | 81 base::LazyInstance<MailboxManagerSync::TextureGroup::MailboxToGroupMap>:: |
81 MailboxManagerSync::TextureGroup::mailbox_to_group_ = | 82 DestructorAtExit MailboxManagerSync::TextureGroup::mailbox_to_group_ = |
82 LAZY_INSTANCE_INITIALIZER; | 83 LAZY_INSTANCE_INITIALIZER; |
83 | 84 |
84 // static | 85 // static |
85 MailboxManagerSync::TextureGroup* MailboxManagerSync::TextureGroup::FromName( | 86 MailboxManagerSync::TextureGroup* MailboxManagerSync::TextureGroup::FromName( |
86 const Mailbox& name) { | 87 const Mailbox& name) { |
87 MailboxToGroupMap::iterator it = mailbox_to_group_.Get().find(name); | 88 MailboxToGroupMap::iterator it = mailbox_to_group_.Get().find(name); |
88 if (it == mailbox_to_group_.Get().end()) | 89 if (it == mailbox_to_group_.Get().end()) |
89 return NULL; | 90 return NULL; |
90 | 91 |
91 return it->second.get(); | 92 return it->second.get(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 346 |
346 if (!needs_update.empty()) { | 347 if (!needs_update.empty()) { |
347 for (const TextureUpdatePair& pair : needs_update) { | 348 for (const TextureUpdatePair& pair : needs_update) { |
348 pair.second.UpdateTexture(pair.first); | 349 pair.second.UpdateTexture(pair.first); |
349 } | 350 } |
350 } | 351 } |
351 } | 352 } |
352 | 353 |
353 } // namespace gles2 | 354 } // namespace gles2 |
354 } // namespace gpu | 355 } // namespace gpu |
OLD | NEW |