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> |
(...skipping 10 matching lines...) Expand all Loading... |
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> g_lock = LAZY_INSTANCE_INITIALIZER; |
29 | 29 |
30 #if !defined(OS_MACOSX) | 30 #if !defined(OS_MACOSX) |
31 typedef std::map<SyncToken, linked_ptr<gfx::GLFence>> SyncTokenToFenceMap; | 31 typedef std::map<SyncToken, linked_ptr<gl::GLFence>> SyncTokenToFenceMap; |
32 base::LazyInstance<SyncTokenToFenceMap> g_sync_point_to_fence = | 32 base::LazyInstance<SyncTokenToFenceMap> g_sync_point_to_fence = |
33 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
34 base::LazyInstance<std::queue<SyncTokenToFenceMap::iterator>> g_sync_points = | 34 base::LazyInstance<std::queue<SyncTokenToFenceMap::iterator>> g_sync_points = |
35 LAZY_INSTANCE_INITIALIZER; | 35 LAZY_INSTANCE_INITIALIZER; |
36 #endif | 36 #endif |
37 | 37 |
38 void CreateFenceLocked(const SyncToken& sync_token) { | 38 void CreateFenceLocked(const SyncToken& sync_token) { |
39 #if !defined(OS_MACOSX) | 39 #if !defined(OS_MACOSX) |
40 g_lock.Get().AssertAcquired(); | 40 g_lock.Get().AssertAcquired(); |
41 if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL) | 41 if (gl::GetGLImplementation() == gl::kGLImplementationMockGL) |
42 return; | 42 return; |
43 | 43 |
44 std::queue<SyncTokenToFenceMap::iterator>& sync_points = g_sync_points.Get(); | 44 std::queue<SyncTokenToFenceMap::iterator>& sync_points = g_sync_points.Get(); |
45 SyncTokenToFenceMap& sync_point_to_fence = g_sync_point_to_fence.Get(); | 45 SyncTokenToFenceMap& sync_point_to_fence = g_sync_point_to_fence.Get(); |
46 if (sync_token.release_count()) { | 46 if (sync_token.release_count()) { |
47 while (!sync_points.empty() && | 47 while (!sync_points.empty() && |
48 sync_points.front()->second->HasCompleted()) { | 48 sync_points.front()->second->HasCompleted()) { |
49 sync_point_to_fence.erase(sync_points.front()); | 49 sync_point_to_fence.erase(sync_points.front()); |
50 sync_points.pop(); | 50 sync_points.pop(); |
51 } | 51 } |
52 // Need to use EGL fences since we are likely not in a single share group. | 52 // Need to use EGL fences since we are likely not in a single share group. |
53 linked_ptr<gfx::GLFence> fence(make_linked_ptr(new gfx::GLFenceEGL)); | 53 linked_ptr<gl::GLFence> fence(make_linked_ptr(new gl::GLFenceEGL)); |
54 if (fence.get()) { | 54 if (fence.get()) { |
55 std::pair<SyncTokenToFenceMap::iterator, bool> result = | 55 std::pair<SyncTokenToFenceMap::iterator, bool> result = |
56 sync_point_to_fence.insert(std::make_pair(sync_token, fence)); | 56 sync_point_to_fence.insert(std::make_pair(sync_token, fence)); |
57 DCHECK(result.second); | 57 DCHECK(result.second); |
58 sync_points.push(result.first); | 58 sync_points.push(result.first); |
59 } | 59 } |
60 DCHECK(sync_points.size() == sync_point_to_fence.size()); | 60 DCHECK(sync_points.size() == sync_point_to_fence.size()); |
61 } | 61 } |
62 #endif | 62 #endif |
63 } | 63 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 if (!needs_update.empty()) { | 335 if (!needs_update.empty()) { |
336 for (const TextureUpdatePair& pair : needs_update) { | 336 for (const TextureUpdatePair& pair : needs_update) { |
337 pair.second.UpdateTexture(pair.first); | 337 pair.second.UpdateTexture(pair.first); |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 } // namespace gles2 | 342 } // namespace gles2 |
343 } // namespace gpu | 343 } // namespace gpu |
OLD | NEW |