OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/pgl/command_buffer_pepper.h" |
| 6 #include "base/logging.h" |
| 7 |
| 8 using base::SharedMemory; |
| 9 using gpu::Buffer; |
| 10 |
| 11 CommandBufferPepper::CommandBufferPepper(NPP npp, |
| 12 NPDevice* device, |
| 13 NPDeviceContext3D* context) |
| 14 : npp_(npp), |
| 15 device_(device), |
| 16 context_(context) { |
| 17 } |
| 18 |
| 19 CommandBufferPepper::~CommandBufferPepper() { |
| 20 } |
| 21 |
| 22 // Not implemented in CommandBufferPepper. |
| 23 bool CommandBufferPepper::Initialize(int32 size) { |
| 24 NOTREACHED(); |
| 25 return false; |
| 26 } |
| 27 |
| 28 Buffer CommandBufferPepper::GetRingBuffer() { |
| 29 Buffer buffer; |
| 30 buffer.ptr = context_->commandBuffer; |
| 31 buffer.size = context_->commandBufferEntries * sizeof(int32); |
| 32 return buffer; |
| 33 } |
| 34 |
| 35 int32 CommandBufferPepper::GetSize() { |
| 36 return context_->commandBufferEntries; |
| 37 } |
| 38 |
| 39 int32 CommandBufferPepper::SyncOffsets(int32 put_offset) { |
| 40 context_->putOffset = put_offset; |
| 41 if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) |
| 42 return -1; |
| 43 |
| 44 return context_->getOffset; |
| 45 } |
| 46 |
| 47 int32 CommandBufferPepper::GetGetOffset() { |
| 48 int32 value; |
| 49 if (NPERR_NO_ERROR != device_->getStateContext( |
| 50 npp_, |
| 51 context_, |
| 52 NPDeviceContext3DState_GetOffset, |
| 53 &value)) { |
| 54 return -1; |
| 55 } |
| 56 |
| 57 return value; |
| 58 } |
| 59 |
| 60 void CommandBufferPepper::SetGetOffset(int32 get_offset) { |
| 61 // Not implemented by proxy. |
| 62 NOTREACHED(); |
| 63 } |
| 64 |
| 65 int32 CommandBufferPepper::GetPutOffset() { |
| 66 int32 value; |
| 67 if (NPERR_NO_ERROR != device_->getStateContext( |
| 68 npp_, |
| 69 context_, |
| 70 NPDeviceContext3DState_PutOffset, |
| 71 &value)) { |
| 72 return -1; |
| 73 } |
| 74 |
| 75 return value; |
| 76 } |
| 77 |
| 78 int32 CommandBufferPepper::CreateTransferBuffer(size_t size) { |
| 79 int32 id; |
| 80 if (NPERR_NO_ERROR != device_->createBuffer(npp_, context_, size, &id)) |
| 81 return -1; |
| 82 |
| 83 return id; |
| 84 } |
| 85 |
| 86 void CommandBufferPepper::DestroyTransferBuffer(int32 id) { |
| 87 device_->destroyBuffer(npp_, context_, id); |
| 88 } |
| 89 |
| 90 Buffer CommandBufferPepper::GetTransferBuffer(int32 id) { |
| 91 NPDeviceBuffer np_buffer; |
| 92 if (NPERR_NO_ERROR != device_->mapBuffer(npp_, context_, id, &np_buffer)) |
| 93 return Buffer(); |
| 94 |
| 95 Buffer buffer; |
| 96 buffer.ptr = np_buffer.ptr; |
| 97 buffer.size = np_buffer.size; |
| 98 return buffer; |
| 99 } |
| 100 |
| 101 int32 CommandBufferPepper::GetToken() { |
| 102 int32 value; |
| 103 if (NPERR_NO_ERROR != device_->getStateContext( |
| 104 npp_, |
| 105 context_, |
| 106 NPDeviceContext3DState_Token, |
| 107 &value)) { |
| 108 return -1; |
| 109 } |
| 110 |
| 111 return value; |
| 112 } |
| 113 |
| 114 void CommandBufferPepper::SetToken(int32 token) { |
| 115 // Not implemented by proxy. |
| 116 NOTREACHED(); |
| 117 } |
| 118 |
| 119 int32 CommandBufferPepper::ResetParseError() { |
| 120 int32 value; |
| 121 if (NPERR_NO_ERROR != device_->getStateContext( |
| 122 npp_, |
| 123 context_, |
| 124 NPDeviceContext3DState_ParseError, |
| 125 &value)) { |
| 126 return -1; |
| 127 } |
| 128 |
| 129 return value; |
| 130 } |
| 131 |
| 132 void CommandBufferPepper::SetParseError(int32 parse_error) { |
| 133 // Not implemented by proxy. |
| 134 NOTREACHED(); |
| 135 } |
| 136 |
| 137 bool CommandBufferPepper::GetErrorStatus() { |
| 138 int32 value; |
| 139 if (NPERR_NO_ERROR != device_->getStateContext( |
| 140 npp_, |
| 141 context_, |
| 142 NPDeviceContext3DState_ErrorStatus, |
| 143 &value)) { |
| 144 return value != 0; |
| 145 } |
| 146 |
| 147 return true; |
| 148 } |
| 149 |
| 150 void CommandBufferPepper::RaiseErrorStatus() { |
| 151 // Not implemented by proxy. |
| 152 NOTREACHED(); |
| 153 } |
OLD | NEW |