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

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

Issue 1714883002: command_buffer_gles2: Implement EGL default Display as a global object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@command_buffer_gles2-multiple-contexts
Patch Set: Created 4 years, 10 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/vertex_array_manager.h" 5 #include "gpu/command_buffer/service/vertex_array_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 "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 11 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
12 #include "gpu/command_buffer/service/buffer_manager.h" 12 #include "gpu/command_buffer/service/buffer_manager.h"
13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
14 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 14 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
15 15
16 namespace gpu { 16 namespace gpu {
17 namespace gles2 { 17 namespace gles2 {
18 18
19 VertexArrayManager::VertexArrayManager() 19 VertexArrayManager::VertexArrayManager()
20 : vertex_attrib_manager_count_(0), 20 : vertex_attrib_manager_count_(0),
21 have_context_(true) { 21 have_context_(true) {
22 } 22 }
23 23
24 VertexArrayManager::~VertexArrayManager() { 24 VertexArrayManager::~VertexArrayManager() {
25 DCHECK(vertex_attrib_managers_.empty()); 25 DCHECK(client_vertex_attrib_managers_.empty());
26 DCHECK(other_vertex_attrib_managers_.empty());
26 CHECK_EQ(vertex_attrib_manager_count_, 0u); 27 CHECK_EQ(vertex_attrib_manager_count_, 0u);
27 } 28 }
28 29
29 void VertexArrayManager::Destroy(bool have_context) { 30 void VertexArrayManager::Destroy(bool have_context) {
30 have_context_ = have_context; 31 have_context_ = have_context;
31 vertex_attrib_managers_.clear(); 32 client_vertex_attrib_managers_.clear();
33 other_vertex_attrib_managers_.clear();
32 } 34 }
33 35
34 scoped_refptr<VertexAttribManager> 36 scoped_refptr<VertexAttribManager>
35 VertexArrayManager::CreateVertexAttribManager(GLuint client_id, 37 VertexArrayManager::CreateVertexAttribManager(GLuint client_id,
36 GLuint service_id, 38 GLuint service_id,
37 uint32_t num_vertex_attribs, 39 uint32_t num_vertex_attribs,
38 bool client_visible) { 40 bool client_visible) {
39 scoped_refptr<VertexAttribManager> vertex_attrib_manager( 41 scoped_refptr<VertexAttribManager> vertex_attrib_manager(
40 new VertexAttribManager(this, service_id, num_vertex_attribs)); 42 new VertexAttribManager(this, service_id, num_vertex_attribs));
41 43
42 if (client_visible) { 44 if (client_visible) {
43 std::pair<VertexAttribManagerMap::iterator, bool> result = 45 std::pair<VertexAttribManagerMap::iterator, bool> result =
44 vertex_attrib_managers_.insert( 46 client_vertex_attrib_managers_.insert(
45 std::make_pair(client_id, vertex_attrib_manager)); 47 std::make_pair(client_id, vertex_attrib_manager));
46 DCHECK(result.second); 48 DCHECK(result.second);
49 } else {
50 other_vertex_attrib_managers_.push_back(vertex_attrib_manager);
47 } 51 }
48 52
49 return vertex_attrib_manager; 53 return vertex_attrib_manager;
50 } 54 }
51 55
52 VertexAttribManager* VertexArrayManager::GetVertexAttribManager( 56 VertexAttribManager* VertexArrayManager::GetVertexAttribManager(
53 GLuint client_id) { 57 GLuint client_id) {
54 VertexAttribManagerMap::iterator it = vertex_attrib_managers_.find(client_id); 58 VertexAttribManagerMap::iterator it =
55 return it != vertex_attrib_managers_.end() ? it->second.get() : NULL; 59 client_vertex_attrib_managers_.find(client_id);
60 return it != client_vertex_attrib_managers_.end() ? it->second.get() : NULL;
56 } 61 }
57 62
58 void VertexArrayManager::RemoveVertexAttribManager(GLuint client_id) { 63 void VertexArrayManager::RemoveVertexAttribManager(GLuint client_id) {
59 VertexAttribManagerMap::iterator it = vertex_attrib_managers_.find(client_id); 64 VertexAttribManagerMap::iterator it =
60 if (it != vertex_attrib_managers_.end()) { 65 client_vertex_attrib_managers_.find(client_id);
66 if (it != client_vertex_attrib_managers_.end()) {
61 VertexAttribManager* vertex_attrib_manager = it->second.get(); 67 VertexAttribManager* vertex_attrib_manager = it->second.get();
62 vertex_attrib_manager->MarkAsDeleted(); 68 vertex_attrib_manager->MarkAsDeleted();
63 vertex_attrib_managers_.erase(it); 69 client_vertex_attrib_managers_.erase(it);
64 } 70 }
65 } 71 }
66 72
67 void VertexArrayManager::StartTracking( 73 void VertexArrayManager::StartTracking(
68 VertexAttribManager* /* vertex_attrib_manager */) { 74 VertexAttribManager* /* vertex_attrib_manager */) {
69 ++vertex_attrib_manager_count_; 75 ++vertex_attrib_manager_count_;
70 } 76 }
71 77
72 void VertexArrayManager::StopTracking( 78 void VertexArrayManager::StopTracking(
73 VertexAttribManager* /* vertex_attrib_manager */) { 79 VertexAttribManager* /* vertex_attrib_manager */) {
74 --vertex_attrib_manager_count_; 80 --vertex_attrib_manager_count_;
75 } 81 }
76 82
77 bool VertexArrayManager::GetClientId( 83 bool VertexArrayManager::GetClientId(
78 GLuint service_id, GLuint* client_id) const { 84 GLuint service_id, GLuint* client_id) const {
79 // This doesn't need to be fast. It's only used during slow queries. 85 // This doesn't need to be fast. It's only used during slow queries.
80 for (VertexAttribManagerMap::const_iterator it = 86 for (VertexAttribManagerMap::const_iterator it =
81 vertex_attrib_managers_.begin(); 87 client_vertex_attrib_managers_.begin();
Sami Väisänen 2016/02/19 14:10:15 Could this simply use std::find_if ?
Kimmo Kinnunen 2016/02/22 06:43:08 Yeah, but it's existing code which the patch doesn
82 it != vertex_attrib_managers_.end(); ++it) { 88 it != client_vertex_attrib_managers_.end(); ++it) {
83 if (it->second->service_id() == service_id) { 89 if (it->second->service_id() == service_id) {
84 *client_id = it->first; 90 *client_id = it->first;
85 return true; 91 return true;
86 } 92 }
87 } 93 }
88 return false; 94 return false;
89 } 95 }
90 96
91 } // namespace gles2 97 } // namespace gles2
92 } // namespace gpu 98 } // namespace gpu
93 99
94 100
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698