• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "dawn_wire/WireServer.h"
16 #include "dawn_wire/server/Server.h"
17 
18 namespace dawn_wire {
19 
WireServer(const WireServerDescriptor & descriptor)20     WireServer::WireServer(const WireServerDescriptor& descriptor)
21         : mImpl(new server::Server(*descriptor.procs,
22                                    descriptor.serializer,
23                                    descriptor.memoryTransferService)) {
24     }
25 
~WireServer()26     WireServer::~WireServer() {
27         mImpl.reset();
28     }
29 
HandleCommands(const volatile char * commands,size_t size)30     const volatile char* WireServer::HandleCommands(const volatile char* commands, size_t size) {
31         return mImpl->HandleCommands(commands, size);
32     }
33 
InjectTexture(WGPUTexture texture,uint32_t id,uint32_t generation,uint32_t deviceId,uint32_t deviceGeneration)34     bool WireServer::InjectTexture(WGPUTexture texture,
35                                    uint32_t id,
36                                    uint32_t generation,
37                                    uint32_t deviceId,
38                                    uint32_t deviceGeneration) {
39         return mImpl->InjectTexture(texture, id, generation, deviceId, deviceGeneration);
40     }
41 
InjectSwapChain(WGPUSwapChain swapchain,uint32_t id,uint32_t generation,uint32_t deviceId,uint32_t deviceGeneration)42     bool WireServer::InjectSwapChain(WGPUSwapChain swapchain,
43                                      uint32_t id,
44                                      uint32_t generation,
45                                      uint32_t deviceId,
46                                      uint32_t deviceGeneration) {
47         return mImpl->InjectSwapChain(swapchain, id, generation, deviceId, deviceGeneration);
48     }
49 
InjectDevice(WGPUDevice device,uint32_t id,uint32_t generation)50     bool WireServer::InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation) {
51         return mImpl->InjectDevice(device, id, generation);
52     }
53 
GetDevice(uint32_t id,uint32_t generation)54     WGPUDevice WireServer::GetDevice(uint32_t id, uint32_t generation) {
55         return mImpl->GetDevice(id, generation);
56     }
57 
58     namespace server {
59         MemoryTransferService::MemoryTransferService() = default;
60 
61         MemoryTransferService::~MemoryTransferService() = default;
62 
63         MemoryTransferService::ReadHandle::ReadHandle() = default;
64 
65         MemoryTransferService::ReadHandle::~ReadHandle() = default;
66 
67         MemoryTransferService::WriteHandle::WriteHandle() = default;
68 
69         MemoryTransferService::WriteHandle::~WriteHandle() = default;
70 
SetTarget(void * data)71         void MemoryTransferService::WriteHandle::SetTarget(void* data) {
72             mTargetData = data;
73         }
SetDataLength(size_t dataLength)74         void MemoryTransferService::WriteHandle::SetDataLength(size_t dataLength) {
75             mDataLength = dataLength;
76         }
77     }  // namespace server
78 
79 }  // namespace dawn_wire
80