diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-08 18:31:08 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-08 18:31:08 +0000 |
commit | 20407e957e31a0faf159403d47dc5d1d6c903f9e (patch) | |
tree | 350962b37d2cb6d9e0fdae78a24efb2bd3c72723 /gpu/command_buffer/client | |
parent | 9283f2789927383ece6aedbd948a645164c35c53 (diff) | |
download | chromium_src-20407e957e31a0faf159403d47dc5d1d6c903f9e.zip chromium_src-20407e957e31a0faf159403d47dc5d1d6c903f9e.tar.gz chromium_src-20407e957e31a0faf159403d47dc5d1d6c903f9e.tar.bz2 |
Removed dependencies on base from GPU common and client code.
The main change was to make scoped_ptr and the basic types the same for both NaCl and trusted plugins and to implement new logging code for GPU common and client code. Service code and unit tests can still use the logging code in base.
I am really not happy with the new logging code but I thought I'd let you take a look at it to see what you think. The biggest thing I don't like is it uses assert(false) to throw an exception in a platform independent way, which brings up a modal dialog. Not ideal in the middle of a unit test run. I don't know if that will make the bots hang. Hopefully they'll time out or something.
TEST=try
BUG=none
Review URL: http://codereview.chromium.org/2936009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58857 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper.cc | 10 | ||||
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator.cc | 18 | ||||
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator_test.cc | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_c.c | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_cc.cc | 16 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 14 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 15 | ||||
-rw-r--r-- | gpu/command_buffer/client/mapped_memory.cc | 39 | ||||
-rw-r--r-- | gpu/command_buffer/client/mapped_memory.h | 16 | ||||
-rw-r--r-- | gpu/command_buffer/client/mapped_memory_unittest.cc | 5 | ||||
-rw-r--r-- | gpu/command_buffer/client/ring_buffer.cc | 17 | ||||
-rw-r--r-- | gpu/command_buffer/client/ring_buffer.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/ring_buffer_test.cc | 2 |
14 files changed, 92 insertions, 70 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc index ceec30e..b666e83 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper.cc @@ -77,7 +77,7 @@ int32 CommandBufferHelper::InsertToken() { if (token_ == 0) { // we wrapped Finish(); - DCHECK_EQ(token_, last_token_read_); + GPU_DCHECK_EQ(token_, last_token_read_); } return token_; } @@ -93,7 +93,7 @@ void CommandBufferHelper::WaitForToken(int32 token) { Flush(); while (last_token_read_ < token) { if (get_ == put_) { - LOG(FATAL) << "Empty command buffer while waiting on a token."; + GPU_LOG(FATAL) << "Empty command buffer while waiting on a token."; return; } // Do not loop forever if the flush fails, meaning the command buffer reader @@ -109,13 +109,13 @@ void CommandBufferHelper::WaitForToken(int32 token) { // function will return early if an error occurs, in which case the available // space may not be available. void CommandBufferHelper::WaitForAvailableEntries(int32 count) { - CHECK(count < usable_entry_count_); + GPU_CHECK(count < usable_entry_count_); if (put_ + count > usable_entry_count_) { // There's not enough room between the current put and the end of the // buffer, so we need to wrap. We will add a jump back to the start, but we // need to make sure get wraps first, actually that get is 1 or more (since // put will wrap to 0 after we add the jump). - DCHECK_LE(1, put_); + GPU_DCHECK_LE(1, put_); Flush(); while (get_ > put_ || get_ == 0) { // Do not loop forever if the flush fails, meaning the command buffer @@ -143,7 +143,7 @@ CommandBufferEntry* CommandBufferHelper::GetSpace(uint32 entries) { WaitForAvailableEntries(entries); CommandBufferEntry* space = &entries_[put_]; put_ += entries; - DCHECK_LE(put_, usable_entry_count_); + GPU_DCHECK_LE(put_, usable_entry_count_); if (put_ == usable_entry_count_) { cmd::Jump::Set(&entries_[put_], 0); put_ = 0; diff --git a/gpu/command_buffer/client/fenced_allocator.cc b/gpu/command_buffer/client/fenced_allocator.cc index a58046e..3fc625d 100644 --- a/gpu/command_buffer/client/fenced_allocator.cc +++ b/gpu/command_buffer/client/fenced_allocator.cc @@ -10,7 +10,7 @@ namespace gpu { -#ifndef COMPILER_MSVC +#ifndef _MSC_VER const FencedAllocator::Offset FencedAllocator::kInvalidOffset; #endif @@ -22,8 +22,8 @@ FencedAllocator::~FencedAllocator() { } } // These checks are not valid if the service has crashed or lost the context. - // DCHECK_EQ(blocks_.size(), 1u); - // DCHECK_EQ(blocks_[0].state, FREE); + // GPU_DCHECK_EQ(blocks_.size(), 1u); + // GPU_DCHECK_EQ(blocks_[0].state, FREE); } // Looks for a non-allocated block that is big enough. Search in the FREE @@ -60,7 +60,7 @@ FencedAllocator::Offset FencedAllocator::Alloc(unsigned int size) { // necessary. void FencedAllocator::Free(FencedAllocator::Offset offset) { BlockIndex index = GetBlockByOffset(offset); - DCHECK_NE(blocks_[index].state, FREE); + GPU_DCHECK_NE(blocks_[index].state, FREE); blocks_[index].state = FREE; CollapseFreeBlock(index); } @@ -96,7 +96,7 @@ unsigned int FencedAllocator::GetLargestFreeOrPendingSize() { max_size = std::max(max_size, current_size); current_size = 0; } else { - DCHECK(block.state == FREE || block.state == FREE_PENDING_TOKEN); + GPU_DCHECK(block.state == FREE || block.state == FREE_PENDING_TOKEN); current_size += block.size; } } @@ -149,7 +149,7 @@ FencedAllocator::BlockIndex FencedAllocator::CollapseFreeBlock( FencedAllocator::BlockIndex FencedAllocator::WaitForTokenAndFreeBlock( BlockIndex index) { Block &block = blocks_[index]; - DCHECK_EQ(block.state, FREE_PENDING_TOKEN); + GPU_DCHECK_EQ(block.state, FREE_PENDING_TOKEN); helper_->WaitForToken(block.token); block.state = FREE; return CollapseFreeBlock(index); @@ -174,8 +174,8 @@ void FencedAllocator::FreeUnused() { FencedAllocator::Offset FencedAllocator::AllocInBlock(BlockIndex index, unsigned int size) { Block &block = blocks_[index]; - DCHECK_GE(block.size, size); - DCHECK_EQ(block.state, FREE); + GPU_DCHECK_GE(block.size, size); + GPU_DCHECK_EQ(block.state, FREE); Offset offset = block.offset; if (block.size == size) { block.state = IN_USE; @@ -194,7 +194,7 @@ FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { Block templ = { IN_USE, offset, 0, kUnusedToken }; Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(), templ, OffsetCmp()); - DCHECK(it != blocks_.end() && it->offset == offset); + GPU_DCHECK(it != blocks_.end() && it->offset == offset); return it-blocks_.begin(); } diff --git a/gpu/command_buffer/client/fenced_allocator.h b/gpu/command_buffer/client/fenced_allocator.h index cbb133d..fb97e37 100644 --- a/gpu/command_buffer/client/fenced_allocator.h +++ b/gpu/command_buffer/client/fenced_allocator.h @@ -182,7 +182,7 @@ class FencedAllocatorWrapper { // Parameters: // pointer: the pointer to the memory block to free. void Free(void *pointer) { - DCHECK(pointer); + GPU_DCHECK(pointer); allocator_.Free(GetOffset(pointer)); } @@ -193,7 +193,7 @@ class FencedAllocatorWrapper { // pointer: the pointer to the memory block to free. // token: the token value to wait for before re-using the memory. void FreePendingToken(void *pointer, int32 token) { - DCHECK(pointer); + GPU_DCHECK(pointer); allocator_.FreePendingToken(GetOffset(pointer), token); } diff --git a/gpu/command_buffer/client/fenced_allocator_test.cc b/gpu/command_buffer/client/fenced_allocator_test.cc index 46f777c..4b66aab 100644 --- a/gpu/command_buffer/client/fenced_allocator_test.cc +++ b/gpu/command_buffer/client/fenced_allocator_test.cc @@ -75,7 +75,7 @@ class BaseFencedAllocatorTest : public testing::Test { scoped_ptr<CommandBufferHelper> helper_; }; -#ifndef COMPILER_MSVC +#ifndef _MSC_VER const unsigned int BaseFencedAllocatorTest::kBufferSize; #endif diff --git a/gpu/command_buffer/client/gles2_demo_c.c b/gpu/command_buffer/client/gles2_demo_c.c index aa83b57..e369745 100644 --- a/gpu/command_buffer/client/gles2_demo_c.c +++ b/gpu/command_buffer/client/gles2_demo_c.c @@ -6,7 +6,7 @@ // includes where appropriate. #include <GLES2/gl2.h> -#include "gpu/command_buffer/client/gles2_demo_c.h" +#include "command_buffer/client/gles2_demo_c.h" void GLFromCDraw() { // glClear(GL_COLOR_BUFFER_BIT); diff --git a/gpu/command_buffer/client/gles2_demo_cc.cc b/gpu/command_buffer/client/gles2_demo_cc.cc index 1e11383..cb33f8c 100644 --- a/gpu/command_buffer/client/gles2_demo_cc.cc +++ b/gpu/command_buffer/client/gles2_demo_cc.cc @@ -5,8 +5,8 @@ // This file is here so other GLES2 related files can have a common set of // includes where appropriate. -#include "gpu/command_buffer/client/gles2_demo_cc.h" -#include "gpu/command_buffer/common/logging.h" +#include "../client/gles2_demo_cc.h" +#include "../common/logging.h" #include <math.h> #include <string> @@ -14,7 +14,7 @@ // This is here so we have at least some idea that the inline path is working. #define GLES2_INLINE_OPTIMIZATION #include <GLES2/gl2.h> -#include "gpu/command_buffer/common/logging.h" +#include "../common/logging.h" namespace { @@ -30,8 +30,8 @@ void CheckGLError(const char* func_name, int line_no) { #ifndef NDEBUG GLenum error = GL_NO_ERROR; while ((error = glGetError()) != GL_NO_ERROR) { - DLOG(ERROR) << "GL Error in " << func_name << " at line " << line_no - << ": " << error; + GPU_DLOG(gpu::ERROR) << "GL Error in " << func_name << " at line " + << line_no << ": " << error; } #endif } @@ -54,7 +54,7 @@ GLuint LoadShader(GLenum type, const char* shaderSrc) { GLsizei length = 0; glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer); std::string log(buffer, length); - DLOG(ERROR) << "Error compiling shader:" << log; + GPU_DLOG(gpu::ERROR) << "Error compiling shader:" << log; glDeleteShader(shader); return 0; } @@ -88,7 +88,7 @@ void InitShaders() { // Create the program object GLuint programObject = glCreateProgram(); if (programObject == 0) { - DLOG(ERROR) << "Creating program failed"; + GPU_DLOG(gpu::ERROR) << "Creating program failed"; return; } glAttachShader(programObject, vertexShader); @@ -107,7 +107,7 @@ void InitShaders() { GLsizei length = 0; glGetProgramInfoLog(programObject, sizeof(buffer), &length, buffer); std::string log(buffer, length); - DLOG(ERROR) << "Error linking program:" << log; + GPU_DLOG(gpu::ERROR) << "Error linking program:" << log; glDeleteProgram(programObject); return; } diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 52afc74..6dad4e2 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -322,7 +322,7 @@ class ClientSideBufferHelper { ii, info.size(), info.type(), info.normalized(), 0, array_buffer_offset_); array_buffer_offset_ += RoundUpToMultipleOf4(bytes_collected); - DCHECK_LE(array_buffer_offset_, array_buffer_size_); + GPU_DCHECK_LE(array_buffer_offset_, array_buffer_size_); } } } @@ -388,7 +388,7 @@ class ClientSideBufferHelper { #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_BUFFERS) -#if !defined(COMPILER_MSVC) +#if !defined(_MSC_VER) const size_t GLES2Implementation::kMaxSizeOfSimpleResult; #endif @@ -502,7 +502,7 @@ void GLES2Implementation::SetGLError(GLenum error, const char* msg) { void GLES2Implementation::GetBucketContents(uint32 bucket_id, std::vector<int8>* data) { - DCHECK(data); + GPU_DCHECK(data); typedef cmd::GetBucketSize::Result Result; Result* result = GetResultAs<Result*>(); *result = 0; @@ -534,7 +534,7 @@ void GLES2Implementation::GetBucketContents(uint32 bucket_id, void GLES2Implementation::SetBucketContents( uint32 bucket_id, const void* data, size_t size) { - DCHECK(data); + GPU_DCHECK(data); helper_->SetBucketSize(bucket_id, size); if (size > 0u) { uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); @@ -566,7 +566,7 @@ void GLES2Implementation::SetBucketAsCString( bool GLES2Implementation::GetBucketAsString( uint32 bucket_id, std::string* str) { - DCHECK(str); + GPU_DCHECK(str); std::vector<int8> data; // NOTE: strings are passed NULL terminated. That means the empty // string will have a size of 1 and no-string will have a size of 0 @@ -842,7 +842,7 @@ void GLES2Implementation::ShaderSource( } } - DCHECK_EQ(total_size, offset); + GPU_DCHECK_EQ(total_size, offset); helper_->ShaderSourceBucket(shader, kResultBucketId); helper_->SetBucketSize(kResultBucketId, 0); @@ -1155,7 +1155,7 @@ const GLubyte* GLES2Implementation::GetString(GLenum name) { if (GetBucketAsString(kResultBucketId, &str)) { std::pair<GLStringMap::const_iterator, bool> insert_result = gl_strings_.insert(std::make_pair(name, str)); - DCHECK(insert_result.second); + GPU_DCHECK(insert_result.second); result = insert_result.first->second.c_str(); } else { result = NULL; diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index a251ee9..fc2bde9 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -57,21 +57,21 @@ class GLES2MockCommandBufferHelper : public CommandBuffer { } virtual void DestroyTransferBuffer(int32) { // NOLINT - NOTREACHED(); + GPU_NOTREACHED(); } virtual Buffer GetTransferBuffer(int32 id) { - DCHECK_EQ(id, kTransferBufferId); + GPU_DCHECK_EQ(id, kTransferBufferId); return transfer_buffer_buffer_; } virtual void SetToken(int32 token) { - NOTREACHED(); + GPU_NOTREACHED(); state_.token = token; } virtual void SetParseError(error::Error error) { - NOTREACHED(); + GPU_NOTREACHED(); state_.error = error; } @@ -94,6 +94,11 @@ class MockGLES2CommandBuffer : public GLES2MockCommandBufferHelper { MOCK_METHOD1(OnFlush, void(void* result)); }; +// GCC requires these declarations, but MSVC requires they not be present +#ifndef _MSC_VER +const int32 GLES2MockCommandBufferHelper::kTransferBufferId; +#endif + namespace gles2 { using testing::Return; @@ -202,7 +207,7 @@ class GLES2ImplementationTest : public testing::Test { }; // GCC requires these declarations, but MSVC requires they not be present -#ifndef COMPILER_MSVC +#ifndef _MSC_VER const int32 GLES2ImplementationTest::kTransferBufferId; #endif diff --git a/gpu/command_buffer/client/mapped_memory.cc b/gpu/command_buffer/client/mapped_memory.cc index 7aafe0a..d2c4886 100644 --- a/gpu/command_buffer/client/mapped_memory.cc +++ b/gpu/command_buffer/client/mapped_memory.cc @@ -2,10 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "gpu/command_buffer/client/mapped_memory.h" -#include "gpu/command_buffer/client/cmd_buffer_helper.h" +#include <algorithm> +#include <functional> + +#include "../client/mapped_memory.h" +#include "../client/cmd_buffer_helper.h" namespace gpu { +namespace { +void DeleteMemoryChunk(MemoryChunk* chunk) { + delete chunk; +} +} MemoryChunk::MemoryChunk( int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper) @@ -14,17 +22,24 @@ MemoryChunk::MemoryChunk( allocator_(shm.size, helper, shm.ptr) { } +MappedMemoryManager::~MappedMemoryManager() { + std::for_each(chunks_.begin(), + chunks_.end(), + std::pointer_to_unary_function<MemoryChunk*, void>( + DeleteMemoryChunk)); +} + void* MappedMemoryManager::Alloc( unsigned int size, int32* shm_id, unsigned int* shm_offset) { - DCHECK(shm_id); - DCHECK(shm_offset); + GPU_DCHECK(shm_id); + GPU_DCHECK(shm_offset); // See if any of the chucks can satisfy this request. for (size_t ii = 0; ii < chunks_.size(); ++ii) { - MemoryChunk* chunk = chunks_[ii].get(); + MemoryChunk* chunk = chunks_[ii]; chunk->FreeUnused(); if (chunk->GetLargestFreeSizeWithoutWaiting() >= size) { void* mem = chunk->Alloc(size); - DCHECK(mem); + GPU_DCHECK(mem); *shm_id = chunk->shm_id(); *shm_offset = chunk->GetOffset(mem); return mem; @@ -38,10 +53,10 @@ void* MappedMemoryManager::Alloc( return NULL; } gpu::Buffer shm = cmd_buf->GetTransferBuffer(id); - MemoryChunk::Ref mc(new MemoryChunk(id, shm, helper_)); + MemoryChunk* mc = new MemoryChunk(id, shm, helper_); chunks_.push_back(mc); void* mem = mc->Alloc(size); - DCHECK(mem); + GPU_DCHECK(mem); *shm_id = mc->shm_id(); *shm_offset = mc->GetOffset(mem); return mem; @@ -49,24 +64,24 @@ void* MappedMemoryManager::Alloc( void MappedMemoryManager::Free(void* pointer) { for (size_t ii = 0; ii < chunks_.size(); ++ii) { - MemoryChunk* chunk = chunks_[ii].get(); + MemoryChunk* chunk = chunks_[ii]; if (chunk->IsInChunk(pointer)) { chunk->Free(pointer); return; } } - NOTREACHED(); + GPU_NOTREACHED(); } void MappedMemoryManager::FreePendingToken(void* pointer, int32 token) { for (size_t ii = 0; ii < chunks_.size(); ++ii) { - MemoryChunk* chunk = chunks_[ii].get(); + MemoryChunk* chunk = chunks_[ii]; if (chunk->IsInChunk(pointer)) { chunk->FreePendingToken(pointer, token); return; } } - NOTREACHED(); + GPU_NOTREACHED(); } } // namespace gpu diff --git a/gpu/command_buffer/client/mapped_memory.h b/gpu/command_buffer/client/mapped_memory.h index 95ff24b..dcd0b58 100644 --- a/gpu/command_buffer/client/mapped_memory.h +++ b/gpu/command_buffer/client/mapped_memory.h @@ -6,20 +6,18 @@ #define GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ #include <vector> -#include "base/basictypes.h" -#include "base/ref_counted.h" -#include "gpu/command_buffer/client/fenced_allocator.h" -#include "gpu/command_buffer/common/buffer.h" + +#include "../common/types.h" +#include "../client/fenced_allocator.h" +#include "../common/buffer.h" namespace gpu { class CommandBufferHelper; // Manages a shared memory segment. -class MemoryChunk : public base::RefCounted<MemoryChunk> { +class MemoryChunk { public: - typedef scoped_refptr<MemoryChunk> Ref; - MemoryChunk(int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper); // Gets the size of the largest free block that is available without waiting. @@ -107,6 +105,8 @@ class MappedMemoryManager { : helper_(helper) { } + ~MappedMemoryManager(); + // Allocates a block of memory // Parameters: // size: size of memory to allocate. @@ -132,7 +132,7 @@ class MappedMemoryManager { void FreePendingToken(void* pointer, int32 token); private: - typedef std::vector<MemoryChunk::Ref> MemoryChunkVector; + typedef std::vector<MemoryChunk*> MemoryChunkVector; CommandBufferHelper* helper_; MemoryChunkVector chunks_; diff --git a/gpu/command_buffer/client/mapped_memory_unittest.cc b/gpu/command_buffer/client/mapped_memory_unittest.cc index b983585..4728aee 100644 --- a/gpu/command_buffer/client/mapped_memory_unittest.cc +++ b/gpu/command_buffer/client/mapped_memory_unittest.cc @@ -6,6 +6,7 @@ #include "base/callback.h" #include "base/message_loop.h" #include "base/scoped_nsautorelease_pool.h" +#include "base/scoped_ptr.h" #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/command_buffer_service.h" @@ -89,7 +90,7 @@ class MemoryChunkTest : public MappedMemoryTestBase { gpu::Buffer buf; buf.size = kBufferSize; buf.ptr = buffer_.get(); - chunk_ = new MemoryChunk(kShmId, buf, helper_.get()); + chunk_.reset(new MemoryChunk(kShmId, buf, helper_.get())); } virtual void TearDown() { @@ -99,7 +100,7 @@ class MemoryChunkTest : public MappedMemoryTestBase { MappedMemoryTestBase::TearDown(); } - MemoryChunk::Ref chunk_; + scoped_ptr<MemoryChunk> chunk_; scoped_array<uint8> buffer_; }; diff --git a/gpu/command_buffer/client/ring_buffer.cc b/gpu/command_buffer/client/ring_buffer.cc index 89da7fe..835f430 100644 --- a/gpu/command_buffer/client/ring_buffer.cc +++ b/gpu/command_buffer/client/ring_buffer.cc @@ -27,9 +27,9 @@ RingBuffer::~RingBuffer() { } void RingBuffer::FreeOldestBlock() { - DCHECK(!blocks_.empty()) << "no free blocks"; + GPU_DCHECK(!blocks_.empty()) << "no free blocks"; Block& block = blocks_.front(); - DCHECK(block.valid) << "attempt to allocate more than maximum memory"; + GPU_DCHECK(block.valid) << "attempt to allocate more than maximum memory"; helper_->WaitForToken(block.token); in_use_offset_ += block.size; if (in_use_offset_ == size_) { @@ -44,8 +44,8 @@ void RingBuffer::FreeOldestBlock() { } RingBuffer::Offset RingBuffer::Alloc(unsigned int size) { - DCHECK_LE(size, size_) << "attempt to allocate more than maximum memory"; - DCHECK(blocks_.empty() || blocks_.back().valid) + GPU_DCHECK_LE(size, size_) << "attempt to allocate more than maximum memory"; + GPU_DCHECK(blocks_.empty() || blocks_.back().valid) << "Attempt to alloc another block before freeing the previous."; // Similarly to malloc, an allocation of 0 allocates at least 1 byte, to // return different pointers every time. @@ -68,19 +68,20 @@ RingBuffer::Offset RingBuffer::Alloc(unsigned int size) { void RingBuffer::FreePendingToken(RingBuffer::Offset offset, unsigned int token) { offset -= base_offset_; - DCHECK(!blocks_.empty()) << "no allocations to free"; + GPU_DCHECK(!blocks_.empty()) << "no allocations to free"; for (Container::reverse_iterator it = blocks_.rbegin(); it != blocks_.rend(); ++it) { Block& block = *it; if (block.offset == offset) { - DCHECK(!block.valid) << "block that corresponds to offset already freed"; + GPU_DCHECK(!block.valid) + << "block that corresponds to offset already freed"; block.token = token; block.valid = true; return; } } - NOTREACHED() << "attempt to free non-existant block"; + GPU_NOTREACHED() << "attempt to free non-existant block"; } unsigned int RingBuffer::GetLargestFreeSizeNoWaiting() { @@ -89,7 +90,7 @@ unsigned int RingBuffer::GetLargestFreeSizeNoWaiting() { if (free_offset_ == in_use_offset_) { if (blocks_.empty()) { // The entire buffer is free. - DCHECK_EQ(free_offset_, 0u); + GPU_DCHECK_EQ(free_offset_, 0u); return size_; } else { // The entire buffer is in use. diff --git a/gpu/command_buffer/client/ring_buffer.h b/gpu/command_buffer/client/ring_buffer.h index 38ee912..b7194bb 100644 --- a/gpu/command_buffer/client/ring_buffer.h +++ b/gpu/command_buffer/client/ring_buffer.h @@ -155,7 +155,7 @@ class RingBufferWrapper { // pointer: the pointer to the memory block to free. // token: the token value to wait for before re-using the memory. void FreePendingToken(void* pointer, unsigned int token) { - DCHECK(pointer); + GPU_DCHECK(pointer); allocator_.FreePendingToken(GetOffset(pointer), token); } diff --git a/gpu/command_buffer/client/ring_buffer_test.cc b/gpu/command_buffer/client/ring_buffer_test.cc index 193906a..9ccb9b43 100644 --- a/gpu/command_buffer/client/ring_buffer_test.cc +++ b/gpu/command_buffer/client/ring_buffer_test.cc @@ -76,7 +76,7 @@ class BaseRingBufferTest : public testing::Test { scoped_ptr<CommandBufferHelper> helper_; }; -#ifndef COMPILER_MSVC +#ifndef _MSC_VER const unsigned int BaseRingBufferTest::kBaseOffset; const unsigned int BaseRingBufferTest::kBufferSize; #endif |