Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: gpu/command_buffer/service/mailbox_manager_sync.cc

Issue 2447533002: ui: Add ref-counting to GLFence class.
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, std::unique_ptr<gl::GLFence>> SyncTokenToFenceMap; 31 typedef std::map<SyncToken, scoped_refptr<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 (gl::GetGLImplementation() == gl::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 auto fence = base::MakeUnique<gl::GLFenceEGL>(); 53 auto fence = make_scoped_refptr(new gl::GLFenceEGL);
54 std::pair<SyncTokenToFenceMap::iterator, bool> result = 54 std::pair<SyncTokenToFenceMap::iterator, bool> result =
55 sync_point_to_fence.insert( 55 sync_point_to_fence.insert(std::make_pair(sync_token, fence.get()));
56 std::make_pair(sync_token, std::move(fence)));
57 DCHECK(result.second); 56 DCHECK(result.second);
58 sync_points.push(result.first); 57 sync_points.push(result.first);
59 DCHECK(sync_points.size() == sync_point_to_fence.size()); 58 DCHECK(sync_points.size() == sync_point_to_fence.size());
60 } 59 }
61 #endif 60 #endif
62 } 61 }
63 62
64 void AcquireFenceLocked(const SyncToken& sync_token) { 63 void AcquireFenceLocked(const SyncToken& sync_token) {
65 #if !defined(OS_MACOSX) 64 #if !defined(OS_MACOSX)
66 g_lock.Get().AssertAcquired(); 65 g_lock.Get().AssertAcquired();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 343
345 if (!needs_update.empty()) { 344 if (!needs_update.empty()) {
346 for (const TextureUpdatePair& pair : needs_update) { 345 for (const TextureUpdatePair& pair : needs_update) {
347 pair.second.UpdateTexture(pair.first); 346 pair.second.UpdateTexture(pair.first);
348 } 347 }
349 } 348 }
350 } 349 }
351 350
352 } // namespace gles2 351 } // namespace gles2
353 } // namespace gpu 352 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/query_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698