| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <functional> | 6 #include <functional> |
| 7 | 7 |
| 8 #include "../client/mapped_memory.h" | 8 #include "../client/mapped_memory.h" |
| 9 #include "../client/cmd_buffer_helper.h" | 9 #include "../client/cmd_buffer_helper.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 GPU_DCHECK(mem); | 47 GPU_DCHECK(mem); |
| 48 *shm_id = chunk->shm_id(); | 48 *shm_id = chunk->shm_id(); |
| 49 *shm_offset = chunk->GetOffset(mem); | 49 *shm_offset = chunk->GetOffset(mem); |
| 50 return mem; | 50 return mem; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Make a new chunk to satisfy the request. | 54 // Make a new chunk to satisfy the request. |
| 55 CommandBuffer* cmd_buf = helper_->command_buffer(); | 55 CommandBuffer* cmd_buf = helper_->command_buffer(); |
| 56 unsigned int chunk_size = | 56 unsigned int chunk_size = |
| 57 ((size + chunk_size_multiple_ - 1) / chunk_size_multiple_) * | 57 ((std::max(1u, size) + chunk_size_multiple_ - 1) / chunk_size_multiple_) * |
| 58 chunk_size_multiple_; | 58 chunk_size_multiple_; |
| 59 int32 id = cmd_buf->CreateTransferBuffer(chunk_size, -1); | 59 int32 id = cmd_buf->CreateTransferBuffer(chunk_size, -1); |
| 60 if (id == -1) { | 60 if (id == -1) { |
| 61 return NULL; | 61 return NULL; |
| 62 } | 62 } |
| 63 gpu::Buffer shm = cmd_buf->GetTransferBuffer(id); | 63 gpu::Buffer shm = cmd_buf->GetTransferBuffer(id); |
| 64 MemoryChunk* mc = new MemoryChunk(id, shm, helper_); | 64 MemoryChunk* mc = new MemoryChunk(id, shm, helper_); |
| 65 chunks_.push_back(mc); | 65 chunks_.push_back(mc); |
| 66 void* mem = mc->Alloc(size); | 66 void* mem = mc->Alloc(size); |
| 67 GPU_DCHECK(mem); | 67 GPU_DCHECK(mem); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } else { | 104 } else { |
| 105 ++iter; | 105 ++iter; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace gpu | 110 } // namespace gpu |
| 111 | 111 |
| 112 | 112 |
| 113 | 113 |
| OLD | NEW |