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

Side by Side Diff: core/cross/client_info.h

Issue 155276: Add ClientInfo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2009, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32
33 // This file defines the ClientInfo class.
34
35 #ifndef O3D_CORE_CROSS_CLIENT_INFO_H_
36 #define O3D_CORE_CROSS_CLIENT_INFO_H_
37
38 #include "core/cross/types.h"
39 #include "core/cross/service_locator.h"
40 #include "core/cross/service_implementation.h"
41
42 namespace o3d {
43
44 // This class is used to report infomation about the client.
45 class ClientInfo {
46 public:
47 ClientInfo()
48 : num_objects_(0),
49 texture_memory_used_(0),
50 buffer_memory_used_(0),
51 software_renderer_(false) {
52 }
53
54 // The number of objects the client is currently tracking.
55 int num_objects() const {
56 return num_objects_;
57 }
58
59 // The amount of texture memory used.
60 int texture_memory_used() const {
61 return texture_memory_used_;
62 };
63
64 // The amount of texture memory used.
65 int buffer_memory_used() const {
66 return buffer_memory_used_;
67 }
68
69 // Whether or not we are using the software renderer.
70 bool software_renderer() const {
71 return software_renderer_;
72 }
73
74 private:
75 friend class ClientInfoManager;
76
77 int num_objects_;
78 int texture_memory_used_;
79 int buffer_memory_used_;
80 bool software_renderer_;
81 };
82
83 // A class to manage the client info so other classes can easily look it up.
84 class ClientInfoManager {
85 public:
86 static const InterfaceId kInterfaceId;
87
88 explicit ClientInfoManager(ServiceLocator* service_locator);
89
90 const ClientInfo& client_info();
91
92 // Adds or subtracts from the amount of texture memory used.
93 void AdjustTextureMemoryUsed(int amount) {
94 client_info_.texture_memory_used_ += amount;
95 DCHECK(client_info_.texture_memory_used_ >= 0);
96 }
97
98 // Adds or subtracts from the amount of texture memory used.
99 void AdjustBufferMemoryUsed(int amount) {
100 client_info_.buffer_memory_used_ += amount;
101 DCHECK(client_info_.buffer_memory_used_ >= 0);
102 }
103
104 void SetSoftwareRenderer(bool used) {
105 client_info_.software_renderer_ = used;
106 }
107
108 private:
109 ServiceImplementation<ClientInfoManager> service_;
110
111 ClientInfo client_info_;
112
113 DISALLOW_COPY_AND_ASSIGN(ClientInfoManager);
114 };
115
116 } // namespace o3d
117
118 #endif // O3D_CORE_CROSS_CLIENT_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698