| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_SERVICE_COMMON_DECODER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <stack> | 9 #include <stack> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public: | 50 public: |
| 51 Bucket() : size_(0) { | 51 Bucket() : size_(0) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 size_t size() const { | 54 size_t size() const { |
| 55 return size_; | 55 return size_; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Gets a pointer to a section the bucket. Returns NULL if offset or size is | 58 // Gets a pointer to a section the bucket. Returns NULL if offset or size is |
| 59 // out of range. | 59 // out of range. |
| 60 void* GetData(size_t offset, size_t size) const; | 60 const void* GetData(size_t offset, size_t size) const; |
| 61 | 61 |
| 62 template <typename T> | 62 template <typename T> |
| 63 T GetDataAs(size_t offset, size_t size) const { | 63 T GetDataAs(size_t offset, size_t size) const { |
| 64 return reinterpret_cast<T>(GetData(offset, size)); | 64 return reinterpret_cast<T>(GetData(offset, size)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Sets the size of the bucket. | 67 // Sets the size of the bucket. |
| 68 void SetSize(size_t size); | 68 void SetSize(size_t size); |
| 69 | 69 |
| 70 // Sets a part of the bucket. | 70 // Sets a part of the bucket. |
| 71 // Returns false if offset or size is out of range. | 71 // Returns false if offset or size is out of range. |
| 72 bool SetData(const void* src, size_t offset, size_t size); | 72 bool SetData(const void* src, size_t offset, size_t size); |
| 73 | 73 |
| 74 // Sets the bucket data from a string. Strings are passed NULL terminated to | 74 // Sets the bucket data from a string. |
| 75 // distinguish between empty string and no string. | |
| 76 void SetFromString(const std::string& str); | 75 void SetFromString(const std::string& str); |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 bool OffsetSizeValid(size_t offset, size_t size) const { | 78 bool OffsetSizeValid(size_t offset, size_t size) const { |
| 80 size_t temp = offset + size; | 79 size_t temp = offset + size; |
| 81 return temp <= size_ && temp >= offset; | 80 return temp <= size_ && temp >= offset; |
| 82 } | 81 } |
| 83 | 82 |
| 84 size_t size_; | 83 size_t size_; |
| 85 scoped_array<int8> data_; | 84 scoped_array<int8> data_; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 169 |
| 171 uint32 offset; | 170 uint32 offset; |
| 172 }; | 171 }; |
| 173 std::stack<CommandAddress> call_stack_; | 172 std::stack<CommandAddress> call_stack_; |
| 174 }; | 173 }; |
| 175 | 174 |
| 176 } // namespace gpu | 175 } // namespace gpu |
| 177 | 176 |
| 178 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 177 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 179 | 178 |
| OLD | NEW |