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

Side by Side Diff: gpu/command_buffer/service/fence_manager.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/fence_manager.h" 5 #include "gpu/command_buffer/service/fence_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gl/gl_fence.h" 10 #include "ui/gl/gl_fence.h"
11 11
12 namespace gpu { 12 namespace gpu {
13 namespace gles2 { 13 namespace gles2 {
14 14
15 FenceManager::FenceManager() {} 15 FenceManager::FenceManager() {}
16 16
17 FenceManager::~FenceManager() {} 17 FenceManager::~FenceManager() {}
18 18
19 void FenceManager::Destroy(bool have_context) { 19 void FenceManager::Destroy(bool have_context) {
20 if (!have_context) { 20 if (!have_context) {
21 for (auto& fence_entry : fences_) 21 for (auto& fence_entry : fences_)
22 fence_entry.second.get()->Invalidate(); 22 fence_entry.second.get()->Invalidate();
23 } 23 }
24 fences_.clear(); 24 fences_.clear();
25 } 25 }
26 26
27 void FenceManager::AddFence(std::unique_ptr<gl::GLFence> fence, 27 void FenceManager::AddFence(gl::GLFence* fence, int32_t service_id) {
28 int32_t service_id) {
29 DCHECK(fences_.find(service_id) == fences_.end()); 28 DCHECK(fences_.find(service_id) == fences_.end());
30 fences_[service_id] = std::move(fence); 29 fences_[service_id] = fence;
31 } 30 }
32 31
33 void FenceManager::RemoveFence(int32_t service_id) { 32 void FenceManager::RemoveFence(int32_t service_id) {
34 GLFenceMap::iterator iter = fences_.find(service_id); 33 GLFenceMap::iterator iter = fences_.find(service_id);
35 DCHECK(iter != fences_.end()); 34 DCHECK(iter != fences_.end());
36 fences_.erase(iter); 35 fences_.erase(iter);
37 } 36 }
38 37
39 gl::GLFence* FenceManager::LookupFence(int32_t service_id) { 38 gl::GLFence* FenceManager::LookupFence(int32_t service_id) {
40 GLFenceMap::const_iterator iter = fences_.find(service_id); 39 GLFenceMap::const_iterator iter = fences_.find(service_id);
41 if (iter != fences_.end()) 40 if (iter != fences_.end())
42 return iter->second.get(); 41 return iter->second.get();
43 42
44 return NULL; 43 return NULL;
45 } 44 }
46 45
47 } // namespace gles2 46 } // namespace gles2
48 } // namespace gpu 47 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/fence_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698