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

Side by Side Diff: gpu/command_buffer/common/command_buffer.h

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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 #ifndef GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 5 #ifndef GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
6 #define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 6 #define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "base/macros.h"
8 #include "gpu/command_buffer/common/buffer.h" 12 #include "gpu/command_buffer/common/buffer.h"
9 #include "gpu/command_buffer/common/constants.h" 13 #include "gpu/command_buffer/common/constants.h"
10 #include "gpu/gpu_export.h" 14 #include "gpu/gpu_export.h"
11 15
12 namespace base { 16 namespace base {
13 class SharedMemory; 17 class SharedMemory;
14 } 18 }
15 19
16 namespace gpu { 20 namespace gpu {
17 21
18 // Common interface for CommandBuffer implementations. 22 // Common interface for CommandBuffer implementations.
19 class GPU_EXPORT CommandBuffer { 23 class GPU_EXPORT CommandBuffer {
20 public: 24 public:
21 struct State { 25 struct State {
22 State() 26 State()
23 : get_offset(0), 27 : get_offset(0),
24 token(-1), 28 token(-1),
25 error(error::kNoError), 29 error(error::kNoError),
26 context_lost_reason(error::kUnknown), 30 context_lost_reason(error::kUnknown),
27 generation(0) { 31 generation(0) {
28 } 32 }
29 33
30 // The offset (in entries) from which the reader is reading. 34 // The offset (in entries) from which the reader is reading.
31 int32 get_offset; 35 int32_t get_offset;
32 36
33 // The current token value. This is used by the writer to defer 37 // The current token value. This is used by the writer to defer
34 // changes to shared memory objects until the reader has reached a certain 38 // changes to shared memory objects until the reader has reached a certain
35 // point in the command buffer. The reader is responsible for updating the 39 // point in the command buffer. The reader is responsible for updating the
36 // token value, for example in response to an asynchronous set token command 40 // token value, for example in response to an asynchronous set token command
37 // embedded in the command buffer. The default token value is zero. 41 // embedded in the command buffer. The default token value is zero.
38 int32 token; 42 int32_t token;
39 43
40 // Error status. 44 // Error status.
41 error::Error error; 45 error::Error error;
42 46
43 // Lost context detail information. 47 // Lost context detail information.
44 error::ContextLostReason context_lost_reason; 48 error::ContextLostReason context_lost_reason;
45 49
46 // Generation index of this state. The generation index is incremented every 50 // Generation index of this state. The generation index is incremented every
47 // time a new state is retrieved from the command processor, so that 51 // time a new state is retrieved from the command processor, so that
48 // consistency can be kept even if IPC messages are processed out-of-order. 52 // consistency can be kept even if IPC messages are processed out-of-order.
49 uint32 generation; 53 uint32_t generation;
50 }; 54 };
51 55
52 struct ConsoleMessage { 56 struct ConsoleMessage {
53 // An user supplied id. 57 // An user supplied id.
54 int32 id; 58 int32_t id;
55 // The message. 59 // The message.
56 std::string message; 60 std::string message;
57 }; 61 };
58 62
59 CommandBuffer() { 63 CommandBuffer() {
60 } 64 }
61 65
62 virtual ~CommandBuffer() { 66 virtual ~CommandBuffer() {
63 } 67 }
64 68
65 // Check if a value is between a start and end value, inclusive, allowing 69 // Check if a value is between a start and end value, inclusive, allowing
66 // for wrapping if start > end. 70 // for wrapping if start > end.
67 static bool InRange(int32 start, int32 end, int32 value) { 71 static bool InRange(int32_t start, int32_t end, int32_t value) {
68 if (start <= end) 72 if (start <= end)
69 return start <= value && value <= end; 73 return start <= value && value <= end;
70 else 74 else
71 return start <= value || value <= end; 75 return start <= value || value <= end;
72 } 76 }
73 77
74 // Initialize the command buffer with the given size. 78 // Initialize the command buffer with the given size.
75 virtual bool Initialize() = 0; 79 virtual bool Initialize() = 0;
76 80
77 // Returns the last state without synchronizing with the service. 81 // Returns the last state without synchronizing with the service.
78 virtual State GetLastState() = 0; 82 virtual State GetLastState() = 0;
79 83
80 // Returns the last token without synchronizing with the service. Note that 84 // Returns the last token without synchronizing with the service. Note that
81 // while you could just call GetLastState().token, GetLastState needs to be 85 // while you could just call GetLastState().token, GetLastState needs to be
82 // fast as it is called for every command where GetLastToken is only called 86 // fast as it is called for every command where GetLastToken is only called
83 // by code that needs to know the last token so it can be slower but more up 87 // by code that needs to know the last token so it can be slower but more up
84 // to date than GetLastState. 88 // to date than GetLastState.
85 virtual int32 GetLastToken() = 0; 89 virtual int32_t GetLastToken() = 0;
86 90
87 // The writer calls this to update its put offset. This ensures the reader 91 // The writer calls this to update its put offset. This ensures the reader
88 // sees the latest added commands, and will eventually process them. On the 92 // sees the latest added commands, and will eventually process them. On the
89 // service side, commands are processed up to the given put_offset before 93 // service side, commands are processed up to the given put_offset before
90 // subsequent Flushes on the same GpuChannel. 94 // subsequent Flushes on the same GpuChannel.
91 virtual void Flush(int32 put_offset) = 0; 95 virtual void Flush(int32_t put_offset) = 0;
92 96
93 // As Flush, ensures that on the service side, commands up to put_offset 97 // As Flush, ensures that on the service side, commands up to put_offset
94 // are processed but before subsequent commands on the same GpuChannel but 98 // are processed but before subsequent commands on the same GpuChannel but
95 // flushing to the service may be deferred. 99 // flushing to the service may be deferred.
96 virtual void OrderingBarrier(int32 put_offset) = 0; 100 virtual void OrderingBarrier(int32_t put_offset) = 0;
97 101
98 // The writer calls this to wait until the current token is within a 102 // The writer calls this to wait until the current token is within a
99 // specific range, inclusive. Can return early if an error is generated. 103 // specific range, inclusive. Can return early if an error is generated.
100 virtual void WaitForTokenInRange(int32 start, int32 end) = 0; 104 virtual void WaitForTokenInRange(int32_t start, int32_t end) = 0;
101 105
102 // The writer calls this to wait until the current get offset is within a 106 // The writer calls this to wait until the current get offset is within a
103 // specific range, inclusive. Can return early if an error is generated. 107 // specific range, inclusive. Can return early if an error is generated.
104 virtual void WaitForGetOffsetInRange(int32 start, int32 end) = 0; 108 virtual void WaitForGetOffsetInRange(int32_t start, int32_t end) = 0;
105 109
106 // Sets the buffer commands are read from. 110 // Sets the buffer commands are read from.
107 // Also resets the get and put offsets to 0. 111 // Also resets the get and put offsets to 0.
108 virtual void SetGetBuffer(int32 transfer_buffer_id) = 0; 112 virtual void SetGetBuffer(int32_t transfer_buffer_id) = 0;
109 113
110 // Create a transfer buffer of the given size. Returns its ID or -1 on 114 // Create a transfer buffer of the given size. Returns its ID or -1 on
111 // error. 115 // error.
112 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, 116 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
113 int32* id) = 0; 117 int32_t* id) = 0;
114 118
115 // Destroy a transfer buffer. The ID must be positive. 119 // Destroy a transfer buffer. The ID must be positive.
116 virtual void DestroyTransferBuffer(int32 id) = 0; 120 virtual void DestroyTransferBuffer(int32_t id) = 0;
117 121
118 // The NaCl Win64 build only really needs the struct definitions above; having 122 // The NaCl Win64 build only really needs the struct definitions above; having
119 // GetLastError declared would mean we'd have to also define it, and pull more 123 // GetLastError declared would mean we'd have to also define it, and pull more
120 // of gpu in to the NaCl Win64 build. 124 // of gpu in to the NaCl Win64 build.
121 #if !defined(NACL_WIN64) 125 #if !defined(NACL_WIN64)
122 // TODO(apatrick): this is a temporary optimization while skia is calling 126 // TODO(apatrick): this is a temporary optimization while skia is calling
123 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6 127 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6
124 // ints redundantly when only the error is needed for the CommandBufferProxy 128 // ints redundantly when only the error is needed for the CommandBufferProxy
125 // implementation. 129 // implementation.
126 virtual error::Error GetLastError(); 130 virtual error::Error GetLastError();
127 #endif 131 #endif
128 132
129 private: 133 private:
130 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); 134 DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
131 }; 135 };
132 136
133 } // namespace gpu 137 } // namespace gpu
134 138
135 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ 139 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/cmd_buffer_common.cc ('k') | gpu/command_buffer/common/command_buffer_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698