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

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

Issue 10067035: RefCounted types should not have public destructors, media/ and gpu/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/query_manager.h ('k') | media/audio/audio_input_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/query_manager.h" 5 #include "gpu/command_buffer/service/query_manager.h"
6 #include "base/atomicops.h" 6 #include "base/atomicops.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/service/common_decoder.h" 10 #include "gpu/command_buffer/service/common_decoder.h"
11 #include "gpu/command_buffer/service/feature_info.h" 11 #include "gpu/command_buffer/service/feature_info.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 class AllSamplesPassedQuery : public QueryManager::Query { 16 class AllSamplesPassedQuery : public QueryManager::Query {
17 public: 17 public:
18 AllSamplesPassedQuery( 18 AllSamplesPassedQuery(
19 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, 19 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset,
20 GLuint service_id); 20 GLuint service_id);
21 virtual ~AllSamplesPassedQuery();
22 virtual bool Begin() OVERRIDE; 21 virtual bool Begin() OVERRIDE;
23 virtual bool End(uint32 submit_count) OVERRIDE; 22 virtual bool End(uint32 submit_count) OVERRIDE;
24 virtual bool Process() OVERRIDE; 23 virtual bool Process() OVERRIDE;
25 virtual void Destroy(bool have_context) OVERRIDE; 24 virtual void Destroy(bool have_context) OVERRIDE;
26 25
26 protected:
27 virtual ~AllSamplesPassedQuery();
28
27 private: 29 private:
28 // Service side query id. 30 // Service side query id.
29 GLuint service_id_; 31 GLuint service_id_;
30 }; 32 };
31 33
32 AllSamplesPassedQuery::AllSamplesPassedQuery( 34 AllSamplesPassedQuery::AllSamplesPassedQuery(
33 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, 35 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset,
34 GLuint service_id) 36 GLuint service_id)
35 : Query(manager, target, shm_id, shm_offset), 37 : Query(manager, target, shm_id, shm_offset),
36 service_id_(service_id) { 38 service_id_(service_id) {
37 } 39 }
38 40
39 AllSamplesPassedQuery::~AllSamplesPassedQuery() {
40 }
41
42 void AllSamplesPassedQuery::Destroy(bool have_context) {
43 if (have_context && !IsDeleted()) {
44 glDeleteQueriesARB(1, &service_id_);
45 MarkAsDeleted();
46 }
47 }
48
49 bool AllSamplesPassedQuery::Begin() { 41 bool AllSamplesPassedQuery::Begin() {
50 BeginQueryHelper(target(), service_id_); 42 BeginQueryHelper(target(), service_id_);
51 return true; 43 return true;
52 } 44 }
53 45
54 bool AllSamplesPassedQuery::End(uint32 submit_count) { 46 bool AllSamplesPassedQuery::End(uint32 submit_count) {
55 EndQueryHelper(target()); 47 EndQueryHelper(target());
56 return AddToPendingQueue(submit_count); 48 return AddToPendingQueue(submit_count);
57 } 49 }
58 50
59 bool AllSamplesPassedQuery::Process() { 51 bool AllSamplesPassedQuery::Process() {
60 GLuint available = 0; 52 GLuint available = 0;
61 glGetQueryObjectuivARB( 53 glGetQueryObjectuivARB(
62 service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); 54 service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available);
63 if (!available) { 55 if (!available) {
64 return true; 56 return true;
65 } 57 }
66 GLuint result = 0; 58 GLuint result = 0;
67 glGetQueryObjectuivARB( 59 glGetQueryObjectuivARB(
68 service_id_, GL_QUERY_RESULT_EXT, &result); 60 service_id_, GL_QUERY_RESULT_EXT, &result);
69 61
70 return MarkAsCompleted(result != 0); 62 return MarkAsCompleted(result != 0);
71 } 63 }
72 64
65 void AllSamplesPassedQuery::Destroy(bool have_context) {
66 if (have_context && !IsDeleted()) {
67 glDeleteQueriesARB(1, &service_id_);
68 MarkAsDeleted();
69 }
70 }
71
72 AllSamplesPassedQuery::~AllSamplesPassedQuery() {
73 }
74
73 class CommandsIssuedQuery : public QueryManager::Query { 75 class CommandsIssuedQuery : public QueryManager::Query {
74 public: 76 public:
75 CommandsIssuedQuery( 77 CommandsIssuedQuery(
76 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); 78 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset);
77 virtual ~CommandsIssuedQuery();
78 79
79 virtual bool Begin() OVERRIDE; 80 virtual bool Begin() OVERRIDE;
80 virtual bool End(uint32 submit_count) OVERRIDE; 81 virtual bool End(uint32 submit_count) OVERRIDE;
81 virtual bool Process() OVERRIDE; 82 virtual bool Process() OVERRIDE;
82 virtual void Destroy(bool have_context) OVERRIDE; 83 virtual void Destroy(bool have_context) OVERRIDE;
83 84
85 protected:
86 virtual ~CommandsIssuedQuery();
87
84 private: 88 private:
85 base::TimeTicks begin_time_; 89 base::TimeTicks begin_time_;
86 }; 90 };
87 91
88 CommandsIssuedQuery::CommandsIssuedQuery( 92 CommandsIssuedQuery::CommandsIssuedQuery(
89 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) 93 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset)
90 : Query(manager, target, shm_id, shm_offset) { 94 : Query(manager, target, shm_id, shm_offset) {
91 } 95 }
92 96
93 CommandsIssuedQuery::~CommandsIssuedQuery() {
94 }
95
96 bool CommandsIssuedQuery::Process() {
97 NOTREACHED();
98 return true;
99 }
100
101 bool CommandsIssuedQuery::Begin() { 97 bool CommandsIssuedQuery::Begin() {
102 begin_time_ = base::TimeTicks::HighResNow(); 98 begin_time_ = base::TimeTicks::HighResNow();
103 return true; 99 return true;
104 } 100 }
105 101
106 bool CommandsIssuedQuery::End(uint32 submit_count) { 102 bool CommandsIssuedQuery::End(uint32 submit_count) {
107 base::TimeDelta elapsed = base::TimeTicks::HighResNow() - begin_time_; 103 base::TimeDelta elapsed = base::TimeTicks::HighResNow() - begin_time_;
108 MarkAsPending(submit_count); 104 MarkAsPending(submit_count);
109 return MarkAsCompleted( 105 return MarkAsCompleted(
110 std::min(elapsed.InMicroseconds(), static_cast<int64>(0xFFFFFFFFL))); 106 std::min(elapsed.InMicroseconds(), static_cast<int64>(0xFFFFFFFFL)));
111 } 107 }
112 108
109 bool CommandsIssuedQuery::Process() {
110 NOTREACHED();
111 return true;
112 }
113
113 void CommandsIssuedQuery::Destroy(bool /* have_context */) { 114 void CommandsIssuedQuery::Destroy(bool /* have_context */) {
114 if (!IsDeleted()) { 115 if (!IsDeleted()) {
115 MarkAsDeleted(); 116 MarkAsDeleted();
116 } 117 }
117 } 118 }
118 119
120 CommandsIssuedQuery::~CommandsIssuedQuery() {
121 }
122
119 QueryManager::QueryManager( 123 QueryManager::QueryManager(
120 CommonDecoder* decoder, 124 CommonDecoder* decoder,
121 FeatureInfo* feature_info) 125 FeatureInfo* feature_info)
122 : decoder_(decoder), 126 : decoder_(decoder),
123 use_arb_occlusion_query2_for_occlusion_query_boolean_( 127 use_arb_occlusion_query2_for_occlusion_query_boolean_(
124 feature_info->feature_flags( 128 feature_info->feature_flags(
125 ).use_arb_occlusion_query2_for_occlusion_query_boolean), 129 ).use_arb_occlusion_query2_for_occlusion_query_boolean),
126 use_arb_occlusion_query_for_occlusion_query_boolean_( 130 use_arb_occlusion_query_for_occlusion_query_boolean_(
127 feature_info->feature_flags( 131 feature_info->feature_flags(
128 ).use_arb_occlusion_query_for_occlusion_query_boolean), 132 ).use_arb_occlusion_query_for_occlusion_query_boolean),
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (!RemovePendingQuery(query)) { 331 if (!RemovePendingQuery(query)) {
328 return false; 332 return false;
329 } 333 }
330 return query->End(submit_count); 334 return query->End(submit_count);
331 } 335 }
332 336
333 } // namespace gles2 337 } // namespace gles2
334 } // namespace gpu 338 } // namespace gpu
335 339
336 340
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.h ('k') | media/audio/audio_input_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698